Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- proclist="firefox gedit xterm" ## List of processes to monitor
- for proc in $proclist;do
- pidof $proc >/dev/null
- if [[ $? -ne 0 ]] ; then
- ## Process 'proc' is NOT running anymore! Do your stuff...
- ## Here we are:
- ## (1) Saving a log with timestamp to /var/log/procmonitor.log (Assuming write permissions on the file)
- ## (2) Using unix mail command to send a email notice (Assuming mail is set up properly)
- echo "[$(date)]: $proc has stopped" | tee -a /var/log/procmonitor.log | mail -s "Process Stopped Notice" receipient@xyz.com
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement