Question

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?

Was it helpful?

Solution

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?

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top