Skip to content

Instantly share code, notes, and snippets.

@rendicott rendicott/check-ps.sh
Last active Jan 4, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.