grep and email
I have an application log which continues to get appended. I would like to grep the log for a string and if it finds the string, I would like an e-mail to be sent out.
I have the command for grep and for e-mail. But not sure how I can join them. I plan to put this is in a cron job which runs daily morning at 09:00 am.
grep -i "Error inserting selected objects"
echo "Error in import script - Auto Generated Mail DO NOT REPLY" | mailx -s "Error in import script...Contact Administrator" 'abc@xyz.com'
So the administrator and other users know that the process might have failed sometime during the night.
Once the error is noted, the administrator manually stops the script, fixes the error, cleans out the log file and restarts the script.
Is there a way to send an e-mail if the grep command is successful?
Thanks in advance.
|