Skip to content

Instantly share code, notes, and snippets.

@rendicott
Last active January 4, 2017 14:58
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 rendicott/e001febfd67dafed0d546b4eafdee121 to your computer and use it in GitHub Desktop.
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
#!/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