public
Last active

Crontab entry to monitor for php-fpm problems

  • Download Gist
phpfpm-mon.cron
1 2 3 4 5
## Auto-restart PHP when it's returning errors
#
# Make sure that http://localhost/test.php is an actual PHP script. If it starts returning
# 500 errors, restart the PHP-FPM service
* * * * * /usr/bin/curl --head -sf http://localhost/test.php -o /dev/null || /usr/sbin/service php5-fpm restart

Try:

* * * * /usr/bin/curl --head -sf http://localhost/test.php -o /dev/null || (/usr/sbin/service php5-fpm restart && /usr/sbin/service nginx restart)

And double-check to make sure the paths are correct for your system.

Thanks, I needed this :)

PS: Your comment has 4 time arguments... shouldn't there be 5?

Thanks a lot! Great way to monitor your php-fpm for the occasional Internal Error 500 hell and keep it up until you find the problem :)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.