If it is a standalone PHP script, you might be interested in daemontools (by D.J. Bernstein, of QMail fame). Instead of starting services directly, the supervise daemon take care of starting those. Whenever it detects that one of the services abort for whatever reason, it attempts to restart it.
You could also run a cron job every minute, and kick-off the script if it's not in the output of something like ps aux | grep <scriptname> | grep -v grep
Should the parent duende process a HUP signal, duende will restart the child process. Should the daemonized or logging process received an untrapped HUP signal or exit with an exit code of 8, duende will restart the process. Should the daemonized or logging process exit for any other reason, duende will send the logger process a TERM signal and exit. Should the duende parent process receive a TERM or INT signal, duende sends all of its children TERM signals, then exits.
If it is a standalone PHP script, you might be interested in daemontools (by D.J. Bernstein, of QMail fame). Instead of starting services directly, the supervise daemon take care of starting those. Whenever it detects that one of the services abort for whatever reason, it attempts to restart it.
Monit is also a good tool for that kind of things.
You could also run a
cron
job every minute, and kick-off the script if it's not in the output of something likeps aux | grep <scriptname> | grep -v grep
You can use
duende
, of maradns fame. From its man page: