What's the best way to keep a PHP script running as a daemon?

后端 未结 9 1132
小蘑菇
小蘑菇 2020-12-24 03:37

What is the best way to keep a PHP script running as a daemon, and what\'s the best way to check if needs restarting.

I have some scripts that need to run 24/7 and f

9条回答
  •  遥遥无期
    2020-12-24 04:17

    We run our daemons by piping the output to mail.

    php daemon.php | mail -s "daemon stopped" foo@example.org
    

    That way, when/if the daemon stops, it will send a mail, and we will be notified that way.

    It still means manual restart of the daemons of course, but we'll know right away. Usually, if the daemons stopped, it means that there is something else that needs to be taken care of anyway, so that's usually ok.

提交回复
热议问题