简体   繁体   中英

Kill Running PHP Script via Process ID?

I make lots of GET requests to several PHP scripts via AJAX. I want to ask for implementation advice on how to kill a PHP script that is currently running (in the background).

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?

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. But even when it is, it is going to be awfully hard to catch the correct PHP process to kill.

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.

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. If you are making a lot of ajax requests, you will definitely kill your server, because it cannot handle an "infinite" amount of connections.

I think you might have to rethink your architecture. You might want to read into COMET and long polling .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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