Last active
January 4, 2017 14:58
-
-
Save rendicott/e001febfd67dafed0d546b4eafdee121 to your computer and use it in GitHub Desktop.
quick dirty bash script to see if there's a running process of the given name with Nagios style return codes
This file contains hidden or 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/bash | |
# Thanks to androidyue on stackoverflow http://stackoverflow.com/questions/2903354/bash-script-to-check-running-process | |
ps_out=`ps -ef | grep $1 | grep -v 'grep' | grep -v $0` | |
result=$(echo $ps_out | grep "$1") | |
if [[ "$result" != "" ]];then | |
echo "$1 Running" | |
exit 0 | |
else | |
echo "$1 Not Running" | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment