Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shell script to look for error in log web server log files
#!/bin/bash
# Shell script to look for error in log web server log files
# -------------------------------------------------------------------------
# http://www.linuxforums.org/forum/red-hat-fedora-linux/166780-shell-script-send-email.html
# -------------------------------------------------------------------------
tail -f -n0 <log-filename> | while read line ; do
if [ $(echo $line | grep -i 'ERROR' | wc -l) != 0 ]; then
(echo "Subject: Fix: Web Server Error"; echo; echo $line) | mail adm@lovemusic.se
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment