Cronjob To Auto Restart PHP Daemon

I wrote about how to create php daemon a few months ago. The php daemon works well, except sometimes somehow the php execution stopped, and the daemon failed to restart the php execution.

That’s why i create a bash script, that will restart the php daemon when the php daemon died. I put this bash script in cronjob to be executed each minute.

Firstly, make sure the php daemon always write the output to a log file. This bash script will check when the log file last mofified, if the log was not modified for a few minutes, then the bash script will restart the php daemon.