Created
November 24, 2011 19:38
-
-
Save kisom/1392113 to your computer and use it in GitHub Desktop.
A very primitive shell script process monitor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# sup.sh | |
# author: kyle isom <[email protected]> | |
# | |
# *extremely* primitive supervisor to ensure a daemon runs and stays running | |
# use it with crontab. | |
# | |
# this is an external supervisor to accompany the monitor python module I wrote | |
# that gets used in the code that's running. | |
# see https://github.com/kisom/pymods/blob/master/monitor.py | |
if [ "x$#" = "x0" ]; then | |
target='/bin/sh ./the_universe.sh' | |
else | |
target="$@" | |
fi | |
mailto="comma,separated,list,of,devs,and,admins,to,alert" | |
count=$(ps ax | grep "${target}" | grep -v $0 | grep -c -v 'grep') | |
if [ "x${count}" = "x0" ]; then | |
echo "${target} not in ps list!" | mail -s "superviser alert!" ${mailto} | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment