Sunday, January 29, 2017

Daily Task Automation : Read the logs and notify

Below script will continuously read the log and will trigger an email if it founds a match for the string


#!/bin/bash

string=fail

while true
do
if tail -f /path/to/file | grep $string
then
echo -e "String found on $HOSTNAME" | mail -s "Subject" dummy@iam.com
fi
done

No comments:

Post a Comment