How to check whether specified PID is currently running without invoking ps from PHP?

后端 未结 9 1862
时光说笑
时光说笑 2020-12-15 03:29

We would like to check if a specified process is currently running via PHP.

We would like to simply supply a PID and see if it is currently executing or not.

9条回答
  •  天涯浪人
    2020-12-15 04:08

    $pid = 12345;
    if (shell_exec("ps ax | grep " . $pid . " | grep -v grep | wc -l") > 0)
    {
        // do something
    }
    

提交回复
热议问题