Re: [PHP] Return to browser and keep running!
Now I noticed you are on windows. There is a user note in the manual that says that this function does not work as expected on windows: [snip] (by priebe at mi-corporation dot com) Note that register_shutdown_function() does not work under Apache on Windows platforms. Your shutdown function will be called, but the connection will not close until the processing is complete. Zend tells me that this is due to a difference between Apache for *nix and Apache for Windows. I'm seeing similar behavior under IIS (using php4isapi). [/snip] But acording to this bug http://bugs.php.net/15209 the behavior changed between php 4.0 and 4.1. There should be new function named apache_register_shutdown_function and I have a feeling I have seen it somewhere in the manual but it seems to be gone. :( Manuel Vázquez Acosta wrote: Add before the exit: set_time_limit(0); http://php.net/set_time_limit Curt You didn't get the idea. I want to be able to keep running a script disconnected from the browser; once all the output has been sent to the browser there's no need for the user to wait until the script finish its execution. set_time_limit(0); makes the scripts to run completely without the 30 seconds error; but it will keep the connection with the browser; so it does not solve the problem though Thanks anyway, Manu. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return to browser and keep running!
Outch! I have read the long discussion of this bug. But I tested the register_shutdown_function on a RH system with Apache 1.3.24 and it didn't work either (the connection keeps alive). The apache_register_shutdown_function doesn't exists in either system. Manu. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return to browser and keep running!
Use register_shutdown_function() Manuel Vázquez Acosta wrote: Hi all: I need to know if there is a way to send the output buffer to the browser, disconnect from it but keep running a task the user doesn't need to realize that is happening and that may take a few minutes to be complete. Something like: ?php /// PREPARE OUTPUT... flush(); disconnect_from_browser(); /// Figure out if its required an optimization pass to /// the DB and make it. This could take a long time before ? Manu. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return to browser and keep running!
Read : PHP's process control functions may do what you need http://us3.php.net/manual/en/ref.pcntl.php Other alternative is to fork an external command with the exec or similar function, which would run another php script, in another php instance, in the background... make sure you redirect all in/out streams and add a sign to the end of the command string, or else you script would hang waiting for child completion... On Wed, 2003-10-15 at 10:52, Manuel Vzquez Acosta wrote: Hi all: I need to know if there is a way to send the output buffer to the browser, disconnect from it but keep running a task the user doesn't need to realize that is happening and that may take a few minutes to be complete. Something like: ?php /// PREPARE OUTPUT... flush(); disconnect_from_browser(); /// Figure out if its required an optimization pass to /// the DB and make it. This could take a long time before ? Manu. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return to browser and keep running!
Marek Kilimajer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Use register_shutdown_function() I made this test: ?php function shutingdown() { $fh = fopen('d:/tmp/test.out', 'w'); if ($fh) { for($i=0; $i1000; $i++) fwrite($fh, $i\n); fclose($fh); } } register_shutdown_function('shutingdown'); echo Running...; flush(); exit(); ? But the browser gets this: Running... Fatal error: Maximum execution time of 30 seconds exceeded in d:\tests\shutdown.php on line 8 My env is: Windows XP-Pro. WebServer: Apache 1.3.24. PHP 4.3.3 (apache module) Thanks and regards, Manu. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return to browser and keep running!
* Thus wrote Manuel Vázquez Acosta ([EMAIL PROTECTED]): Marek Kilimajer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Use register_shutdown_function() register_shutdown_function('shutingdown'); echo Running...; flush(); exit(); ? But the browser gets this: Running... Fatal error: Maximum execution time of 30 seconds exceeded in d:\tests\shutdown.php on line 8 Add before the exit: set_time_limit(0); http://php.net/set_time_limit Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Return to browser and keep running!
Add before the exit: set_time_limit(0); http://php.net/set_time_limit Curt You didn't get the idea. I want to be able to keep running a script disconnected from the browser; once all the output has been sent to the browser there's no need for the user to wait until the script finish its execution. set_time_limit(0); makes the scripts to run completely without the 30 seconds error; but it will keep the connection with the browser; so it does not solve the problem though Thanks anyway, Manu. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Return to browser and keep running!
Manuel Vázquez Acosta mailto:[EMAIL PROTECTED] on Wednesday, October 15, 2003 5:46 PM said: set_time_limit(0); makes the scripts to run completely without the 30 seconds error; but it will keep the connection with the browser; so it does not solve the problem though I think you want to fork your command. I think what you need to do is have the page execute another php page via the commandline. I think that's what you want to do. Chris. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php