How to check if a php script is still running

前端 未结 13 2560
鱼传尺愫
鱼传尺愫 2020-12-15 12:02

I have a PHP script that listens on a queue. Theoretically, it\'s never supposed to die. Is there something to check if it\'s still running? Something like

13条回答
  •  盖世英雄少女心
    2020-12-15 12:43

    Just append a second command after the script. When/if it stops, the second command is invoked. Eg.:

    php daemon.php 2>&1 | mail -s "Daemon stopped" you@example.org
    

    Edit:

    Technically, this invokes the mailer right away, but only completes the command when the php script ends. Doing this captures the output of the php-script and includes in the mail body, which can be useful for debugging what caused the script to halt.

提交回复
热议问题