Skip to content

Instantly share code, notes, and snippets.

@lucianosousa
Created May 31, 2015 16:36
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 lucianosousa/f11de784eec44fcd5f4d to your computer and use it in GitHub Desktop.
Save lucianosousa/f11de784eec44fcd5f4d to your computer and use it in GitHub Desktop.
check if service is running
#!/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