Loading... # [PHP监控一个进程是否在运行的方法](https://blog.p2hp.com/archives/8810) ```php exec("pgrep lighttpd", $pids); if(empty($pids)) { // lighttpd is not running! } pgrep -f 全名匹配. $mabbitmq=shell_exec("pgrep [r]abbitmq"); //https://stackoverflow.com/questions/51551908/why-is-the-result-equal-to-0-and-sometimes-1-shell-execpgrep-f $mabbitmq = str_replace(PHP_EOL, '', $mabbitmq); $mongodb=shell_exec("pgrep [m]ongo"); $mongodb = str_replace(PHP_EOL, '', $mongodb); $ydmcuclient=shell_exec("pgrep -f [y]dmcu_client"); $ydmcuclient = str_replace(PHP_EOL, '', $ydmcuclient); ``` 最后修改:2023 年 08 月 12 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏