Last active
August 29, 2015 14:04
-
-
Save serg-kovalev/e7d441da840f9e646063 to your computer and use it in GitHub Desktop.
This shell script checks if process exists and removes pid file if not. I use this script with monit to be sure that process exist before killing it
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
#!/usr/bin/env bash | |
# the first argument should be a path to pid file | |
if [[ -f "$1" ]] ; then | |
if [ $(ps -p $(cat $1) | wc -l) -gt 1 ] ; then | |
# process exists - do nothing | |
#echo "OK" | |
exit 0 | |
else | |
#echo "will do rm $1" | |
rm $1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment