Skip to content

Instantly share code, notes, and snippets.

@100daysofdevops
Created March 25, 2019 16:17
Show Gist options
  • Select an option

  • Save 100daysofdevops/71afdf18f0f20aecae947c51eb7ffd85 to your computer and use it in GitHub Desktop.

Select an option

Save 100daysofdevops/71afdf18f0f20aecae947c51eb7ffd85 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
function servicecheck()
{
ps aux | grep -v grep |grep $1 >/dev/null
if [ $? != 0 ]
then
echo $1 "is not running";
systemctl start $1
else
echo $1 "is up and running";
fi;
}
servicecheck "httpd"
servicecheck "rsyslogd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment