Skip to content

Instantly share code, notes, and snippets.

@fer-ri
Last active May 7, 2023 11:39
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save fer-ri/6bdfc5d4c9d6d6895480 to your computer and use it in GitHub Desktop.
Save fer-ri/6bdfc5d4c9d6d6895480 to your computer and use it in GitHub Desktop.
Auto Restart PHP5-FPM When Down or Bad Gateway
#!/bin/bash
if curl --head -sf http://yourdomain.com/some-script.php -o /dev/null; then
echo "PHP FPM is up"
else
service php5-fpm restart && service nginx restart && service mysql restart
echo "Opps .. service was down" | mail -s "PHP-FPM Service Down" yourmail@domain.com -aFrom:cron@yourmail.com
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment