Skip to content

Instantly share code, notes, and snippets.

@jacksoncage
Created July 9, 2012 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacksoncage/3076459 to your computer and use it in GitHub Desktop.
Save jacksoncage/3076459 to your computer and use it in GitHub Desktop.
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