Skip to content

Instantly share code, notes, and snippets.

@micahblu
Created November 23, 2015 22:35
Show Gist options
  • Save micahblu/cc60696d77bdcab4be9f to your computer and use it in GitHub Desktop.
Save micahblu/cc60696d77bdcab4be9f to your computer and use it in GitHub Desktop.
Checking for running service, start it if not
#!/bin/bash
service=replace_me_with_a_valid_service
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service start
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment