Created
May 31, 2015 16:36
-
-
Save lucianosousa/f11de784eec44fcd5f4d to your computer and use it in GitHub Desktop.
check if service is running
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/bash | |
commands=("$@") | |
echo "starting monitor check" | |
for command in "${commands[@]}"; do | |
if [ $command == "postgresql93" ] | |
then | |
check="postmaster" | |
else | |
check=$command | |
fi | |
isAlive=`pgrep $check` | |
echo "checking $check with PID $isAlive" | |
if [ -z $isAlive ] | |
then | |
echo "restart $command" | |
service $command restart | |
fi | |
done | |
echo "finish check" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment