I am monitoring a logfile using tail -f file.log|"ERROR"
I would like to write a korn script that monitors this for me and emails me if the event happens. It would be great if it attached the file to the email as well.
Any Ideas?
#!/bin/ksh
tail -f file.log | grep "ERROR" | \
while read line
do
echo $line | mailx -s "Error" you@office.com
done
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.