Skip to content

Instantly share code, notes, and snippets.

@skreutzberger
Created August 8, 2011 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save skreutzberger/1132230 to your computer and use it in GitHub Desktop.
Save skreutzberger/1132230 to your computer and use it in GitHub Desktop.
Keepalive of Nginx
#!/bin/bash
# shell script which checks if nginx is still running
# if not then it restarts the processes, including php-fpm
# this script should be called by a Cronjob every minute
# change the process name to whatever you want to keep alive:
PROCESS="nginx"
if ps ax | grep -v grep | grep $PROCESS > /dev/null
then
echo "$PROCESS is running"
else
echo "$PROCESS is NOT running"
# change the next line to the command you want to run for restarting:
sudo /etc/init.d/php5-fpm restart && sudo /etc/init.d/nginx restart
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment