its been a long time and I cant seem to remember how to do this. I am trying to grep a logfile for a word or words and email if it does not exist in the last fifteen minutes ( I will be setting a cron job every fifteen minutes unless there is a better way to do it) what I have so far is
if grep --quiet 'SEND OK' /logfile; then echo exists else echo not found | mail -s "houston we have a problem" [email protected] fi can I use tail to check the logfile for the last 15 minutes? does |tail -15 do the trick?
and can I give it an "if" to email me if it doesnt find the keyword in the last 15 minutes as it will be run every fifteen minutes
I would greatly appreciate any help
logwatchis what you want? The other suggestion I have is to structure your code so that it outputs nothing in the good case, and only output in the bad case and rely on cron's feature to only email detected output.