[TriLUG] remedial bash scripting question
Joel James Adamson
adamsonj at email.unc.edu
Wed Jun 1 08:48:09 EDT 2011
Robert Dale <robdale at gmail.com> writes:
> On Tue, May 31, 2011 at 8:10 PM, Chris Bullock <cgbullock at yahoo.com> wrote:
>> I have a very basic bash scripting question.
>> I have a log file that I am trying to parse and if the results are positive I
>> want an email sent to me. Then I will put it in a cron tab to run every 15
>> basically. I need this to be a bash script, no perl or awk.
>> # look for the string
> tail -n 1000 /var/log/messages | grep -i mismatch && mail
> me at there.com -s "found the string"
If you put the script in ~/.cron.hourly or /etc/cron.hourly/ then all
output and stderr should be mailed to you (in the latter case if you
have an alias to root in your aliases file). No need for the mail
command. If you use the mail command you will get an email but you may
also get a blank email from the cron daemon.
To Chris: what's your question? I don't see any problems with your
script, have you tested it? Just write the script and put it in the
right cron directory. Or write a wrapper and put the wrapper in the
proper cron directory. Or you can add an entry to the anacrontab(5)
file if you want the job to run every 15 minutes.
Joel J. Adamson
Servedio Lab -- University of North Carolina at Chapel Hill
FSF Member #8164 -- http://www.fsf.org/jf?referrer=8164
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 229 bytes
Desc: not available
More information about the TriLUG