Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Crontab entry to monitor for php-fpm problems
## 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
@dougalcampbell

This comment has been minimized.

Copy link
Owner Author

@dougalcampbell dougalcampbell commented May 14, 2012

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.

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented May 16, 2013

Thanks, I needed this :)

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

@WebBamboo

This comment has been minimized.

Copy link

@WebBamboo WebBamboo commented Sep 2, 2013

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 :)

@ghprod

This comment has been minimized.

Copy link

@ghprod ghprod commented Mar 3, 2016

Thanks a lot :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.