Hello, I am trying to have a script on my Centos 6.5 server send me an email if grep finds particular content inside, for instance, the maillogs.
So I wrote this and put it in the cron.daily directory:
grep -H "spamhaus" /var/log/maillog* | mail -s "Blacklist Alert!" firstname.lastname@example.org
It works, but my problem is I'll get an email even when nothing is found and the body is empty.
So, is there a way to have mail not send anything if the body is empty? I know other mail software can do this with a -E option, but it doesn't seem to work with mail.
Thanks for your help.