AnotherAlan
Technical User
Hi,
For the life of me I cannot work out why this is failing. Instead of the expected result of an email being fired everytime a line containing "failover" occurs it is instead randomly sending emails that lists the full contents of the directory from which the script is run i.e. as if I have piped ls -la into the /tmp/failover.log.
I have used constructs like this a number of times and they work as expected, the only difference being the tail binary.
Any ideas please, i'm seeing stars.
Thanks
For the life of me I cannot work out why this is failing. Instead of the expected result of an email being fired everytime a line containing "failover" occurs it is instead randomly sending emails that lists the full contents of the directory from which the script is run i.e. as if I have piped ls -la into the /tmp/failover.log.
I have used constructs like this a number of times and they work as expected, the only difference being the tail binary.
Any ideas please, i'm seeing stars.
Thanks
Code:
LOG_DIR=/app/log2
LOG_FILE=b.log
NOTIFY_LIST="email"
/usr/xpg4/bin/tail -f -n0 $LOG_DIR/$LOG_FILE | while read line ; do
echo $line | awk '/failover/ {print $0}' > /tmp/failover.log
if [ -s /tmp/failover.log ]; then
mailx -s "Failover Warning" $NOTIFY_LIST < /tmp/failover.log
fi
done