因为要监控php的进程,使用任务管理器以及tasklsit都只能看到php.exe。
无法获取php.exe后面跟的php文件。
可以使用下面方式获取
wmic process where caption="php.exe" get caption,commandline /value
接下来再使用文本查找就可以找到进程是否存在了。
贴一个php的方法。
$tasklist = 'wmic process where caption="php.exe" get caption,commandline /value'; exec($tasklist,$arrProcesslist); $pCount = count($arrProcesslist); $n = 0; // 初始化欲返回的数据 FOR ($i = 0; $i < $pCount; $i++) { if(strpos($arrProcesslist[$i],$pName)){ // 文本查找每行,有就加1. $n++; } } return $n;
这篇文章还没有人留言,快来抢沙发吧。