Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Linux. Act upon an event in a log file
- # www.fduran.com
- apt-get upgrade; apt-get install inotify-tools
- # create file myalert.sh:
- # example finding Exception in tomcat log and sending email
- #!/bin/bash
- while inotifywait -e modify /path/to/file.log; do
- if tail -n1 /path/to/file.log | grep Exception; then
- # your action here
- echo "Exception in tomcat" |mail -s "Exception alert" email@example.com
- fi
- done
- # run with: bash myalert.sh > /dev/null 2>&1 &
- # test with:
- echo "Exception" >> /path/to/file.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement