Page 1 of 1

Check running scripts

Posted: Tue May 02, 2006 2:39 pm
by John Cartwright
I have a script that will be run for about 5 hours, now I have set_time_limit(0) so I want to let it finsih, although even if I click the STOP button in my browser the script still seems to run. Anyone know how to prevent the script from continuing -- this is extremely annoiying :evil:

My next question, is there any way to interact with php to determine which scripts are being run in any way? Yes Im praying for some magical technique.. :(

Posted: Tue May 02, 2006 2:54 pm
by Ambush Commander
I've noticed this problem too. Every once in a while, my complex parser scripts will hit a bug and go into infinite loops. I try a fix, refresh, and then try again. But since the default max execution time is 30 seconds, I easily go up to 8 processes, cumulatively using up all of my CPU (and necessating the manual killing of the processes)

I'd say use command line.

Posted: Tue May 02, 2006 2:57 pm
by Christopher
Or have the script served by the webserver start a command line script and then track progress by the process ID (saved in the session).

Posted: Tue May 02, 2006 3:05 pm
by John Cartwright
Thanks for the comments guys.
arborint wrote:Or have the script served by the webserver start a command line script and then track progress by the process ID (saved in the session).
Can you elaborate a bit on this please?

Posted: Tue May 02, 2006 3:26 pm
by Christopher
You'd probably need to use proc_open() and check with proc_get_status(). But as I recall when I did it a while back without those functions I got the process running and saved the PID in the session. The I could check if that PID was still running as necessary and report whether it was done or not. There was the usual monkeying around to get it to work as I recall.

Posted: Tue May 02, 2006 5:02 pm
by John Cartwright
Thanks again Aborint.