Hi Tapia, i have done some changes in the script. have not run it, just have given scrached on it. You can made some changes and compile it and it should work
let me explan you the logic. put a dummy time stamp in a temp file as
TIMESTAMPF=/tmp/timestamperr.log //put a dummt time like 00:00:00
next search the erro string from your file, get the last line and the time stamp from it and compare with the time stamp in /tmp/timestamperr.log.
if it matches, then there is no error and if it does not then there is error has occured recently.
I hope you got what i am trying to say.
#!/usr/bin/ksh
TIMESTAMPF=/tmp/timestamperr.log //put a dummt time like 00:00:00
grep -i "STOP" $BATE/err.log > /tmp/bbs.lst --capture error into tmp
checkFile=/tmp/bbs.lst
if [ -e $checkFile ]; then ----if file is not empty
ctimeerr=`tail -1 $checkFile | awk '{ print $2 }'` //get the time stamp for the last occured err string
ptimeerr=`head -1 $TIMESTAMPF` //contain the time stamp , dummy one, once only
if [ $timeerr = $ptimeerr ]
then
echo "dont worry process is fine, no errors occured" > /tmp/bbr.log ---throwing into dump
else
tail -1 $checkFile | awk '{ print $2 }' > $TIMESTAMPF
mailx -s 'errors'
XYZ@gmail.com
fi
fi
rm -rf /tmp/bbs.lst -----removing tmp