This command will check your service running or not
addhe.warman@google:~$ if [ -e `ps aux | grep postgresql | grep -v grep` ]; then echo "this is not found"; else echo "this is found"; fi
change the ‘postgresql’ with name of your service…, you can also add some more command to replace echo.