How to check if a php script is still running

monitoring, php, process, queue

Solution

I had the same issue - wanting to check if a script is running. So I came up with this and I run it as a cron job. It grabs the running processes as an array and cycles though each line and checks for the file name. Seems to work fine. Replace #user# with your script user.

exec("ps -U #user# -u #user# u", $output, $result);
foreach ($output AS $line) if(strpos($line, "test.php")) echo "found";

Problem

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 `Ruby's God ( http://god.rubyforge.org/ )` for `PHP`? God is language agnostic but it would be nice to have a solution that works on windows as well.

Original source