Skip to content

Instantly share code, notes, and snippets.

@AysadKozanoglu
Created December 16, 2018 22:40
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 AysadKozanoglu/4298111d6f98b9f79e8c0e0a381ea3de to your computer and use it in GitHub Desktop.
Save AysadKozanoglu/4298111d6f98b9f79e8c0e0a381ea3de to your computer and use it in GitHub Desktop.
#!/bin/sh
# Author: Aysad Kozanoglu
SERVICE='nginx'
DATE=$(date '+%Y-%m-%d %H:%M:%S')
NGINXBIN=$(which nginx)
LOGTO=/var/log/serviceChecker.log
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "$DATE $SERVICE service running, everything is fine" >> $LOGTO
else
echo "$DATE $SERVICE service is not running... starting now " >> $LOGTO
$NGINXBIN
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment