I was able to get my script to successfully email me at regular intervals with the help of another user here. My next question, is that I'd like for it to ONLY email me if the output is not null.
I have a nawk set up to email me the output, and the script is set up to run every 5 minutes via crontab. Due to the number of log files, this would mean that I'd receive 9 emails every 5 minutes which would blow up my inbox.
Current script:
nawk '$0~s{for(c=NR-b;c<=NR+a;c++)r[c]=1}{q[NR]=$0}END{for(c=1;c<=NR;c++)if(r[c])print q[c]}' b=4 a=4 s="Bind value for HASCHILDREN = 0" filename | mail -s "Output from crontask" myemail
Current crontab:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/me/crontask
In order to test the output of the nawk command, you need to save it somewhere. I'd recommend you use a variable:
I assume your shell is bash.