I am executing a script which runs every 30 minutes and greps for a string (FA) in a file and e-mails myself if the string is found, however each time this script runs if the script is found I receive the same information until the next day. I.E. At 08:00 I receive a notification that 3 jobs have failed. Those jobs will remain in the file that I am grep-ing in as FA (failed) because I am appending to the file, however I do not want to receive a notification each time the script runs for a FAILURE which happened hours ago; I only want to be notified of the failure one time. How should I solve this problem? Below is the portion of the script that I am having difficutlies with. Any information will be greatly appreciated.
FAIL=`grep -c FA casfinalreport.$JGDATE4`
if [ $FAIL -ne 0 ]
then
FAILURES=`grep FA casfinalreport.$JGDATE4 | awk -F, '{print $1}'`
for job in `echo $FAILURES`; do
SUBJECT="$SUBJECT $job,"
done
grep FA casfinalreport.$JGDATE4 | awk '{print $1;}' | mailx -s "The Following Job(s) Have Failed: $SUBJECT" test@test.com
fi
Thanks,
John
FAIL=`grep -c FA casfinalreport.$JGDATE4`
if [ $FAIL -ne 0 ]
then
FAILURES=`grep FA casfinalreport.$JGDATE4 | awk -F, '{print $1}'`
for job in `echo $FAILURES`; do
SUBJECT="$SUBJECT $job,"
done
grep FA casfinalreport.$JGDATE4 | awk '{print $1;}' | mailx -s "The Following Job(s) Have Failed: $SUBJECT" test@test.com
fi
Thanks,
John