I have below script to check the word in the driectory /ora_tmp , there are many files in this directory , if the word "error" is exist in any file within 5 day , then send the mail to
ora-usr@mydomain.com about which file have this word and the "error" statement , now , if I want
1. if there is no "error" word existed in any file , then DO NOT send the mail ;
2. send "error" statement to user one time only , that mean , only inform user the "error" statement one time , if there are same "error" statement within 5 days , send the mail to user one time only ( the user need to know the same error one time only ) . can advise how can I change it ? thx.
FILE=/tmp/error ; export FILE
mailfile=/tmp/mailfile ; export mailfile
find /ora_tmp -type f -mtime -5 -maxdepth 1 | xargs grep -i "error" > $FILE
cat $FILE >> $mailfile
echo $mailfile
mail
ora-usr@mydomain.com < $mailfile