如何使用PHP exec()获取正在运行的php脚本的列表? [英] How to get list of running php scripts using PHP exec()?

查看:339
本文介绍了如何使用PHP exec()获取正在运行的php脚本的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道并杀死是否有运行指定PHP脚本的进程.是否有可能使用exec()和php脚本获取运行sample.php的进程的列表.

I need to know and kill if there is any processes running a specified PHP script. Is that possible to get list of processes running sample.php using exec() and a php script.

推荐答案

exec("ps auxwww|grep sample.php|grep -v grep", $output);

这仅在PHP以CGI模式运行时才有效.如果它作为SAPI类型的东西运行,您将永远不会在进程列表中看到"sample.php",而只会看到"httpd".

This would only work, though, if PHP is running in CGI mode. If it's running as a SAPI type thing, you'll never see "sample.php" in the process list, just 'httpd'.

这篇关于如何使用PHP exec()获取正在运行的php脚本的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆