Hello friends, as they are? First of all sorry for my poor English. I tell them what is my problem. I have the following script, which is basically what makes error search for a pattern within a folder containing logs. The script works fine, the problem is that whenever I find a pattern of new error, I send an email with all faults, and I just want to send me new errors found. Can anyone give me a hand? Thank you!
errors=$(grep "System Error Pattern Here" /var/log/)
echo "$errors" > /tmp/current-errors.log
if [ -e "/tmp/prior-errors.log" ]
then echo "prior-errors.log Exists" > /dev/null
else
touch /tmp/prior-errors.log | echo "" > /tmp/prior-errors.log
fi
newentries=$(diff --suppress-common-lines -u /tmp/prior-errors.log /tmp/current-errors.log | grep '+[0-9]')
if
test "$newentries" != "" && test "$errors" = ""
then echo "No New Errors" > /dev/null
elif
test "$newentries" != ""
then echo "$errors" | mailx -s "WARNING: Error Messages Detected" noc@yourcompanyhere.com
echo "$errors" > /tmp/prior-errors.log
fi