简体   繁体   English

通过进程ID杀死正在运行的PHP脚本?

[英]Kill Running PHP Script via Process ID?

I make lots of GET requests to several PHP scripts via AJAX. 我通过AJAX向多个PHP脚本发出了GET请求。 I want to ask for implementation advice on how to kill a PHP script that is currently running (in the background). 我想询问有关如何终止当前正在运行的PHP脚本(在后台)的实施建议。

Is there some way to get the PHP scripts process ID when it runs and then I can probably kill that process via shell/cmd etc? 有什么方法可以在运行时获取PHP脚本的进程ID,然后可以通过shell / cmd等杀死该进程?

Is there a better way? 有没有更好的办法?

Whether PHP is a process of its own at all will depend on how PHP and web server are configured. PHP是否本身就是一个过程,将取决于PHP和Web服务器的配置方式。 But even when it is, it is going to be awfully hard to catch the correct PHP process to kill. 但是即使是这样,要捕获正确的PHP进程也将非常困难。

If you know inside your PHP script that this is the process that needs killing, you may be able to use getmypid() or find something in the User Contributed Notes there. 如果您在PHP脚本中知道这是需要杀死的进程,则可以使用getmypid()或在其中的“用户贡献的说明”中找到某些内容。

I still don't entirely understand the situation. 我仍然不完全了解情况。 Why do you need to kill them at all? 为什么要杀死他们呢?

I did not exactly get, what you are trying to do, but I think you might have reached a part of the web stack that is a dead end. 我没有完全了解您要尝试做的事情,但是我认为您可能已经到达了Web堆栈的死胡同。 If you are making a lot of ajax requests, you will definitely kill your server, because it cannot handle an "infinite" amount of connections. 如果您发出许多ajax请求,则肯定会杀死您的服务器,因为它无法处理“无限”数量的连接。

I think you might have to rethink your architecture. 我认为您可能必须重新考虑您的体系结构。 You might want to read into COMET and long polling . 您可能需要阅读COMET长时间轮询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM