Re: Keeping script running, but returning control to user?

From: Date: Tue, 31 Dec 2002 10:52:29 +0000
Subject: Re: Keeping script running, but returning control to user?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-129754@lists.php.net to get a copy of this message
"Leif K-Brooks" <eurleif@buyer-brokerage.com> wrote in message news:3E10FD15.6020308@buyer-brokerage.com... > I need a way to keep the script running on the server, but control to > the user. I'm doing some lengthy processes on the server, and it seems > stupid to keep the user waiting pointlessly. I'm trying to do something > like: > <?php > if(array_key_exists('secondrun',$_GET)){ > print "Processing complete!"; > exit; > } > header("Location: > > http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?secondrun=1"); > //Do long processing here > ?> > but it waits till the long processing is done, and then redirects. Is > there another way to do this? As you are asking this question, i presume your processing does not return anything that you would need on this page. Here is a simple solution for linux/unix based systems. You put your processing into a command line scirpt (passing it varibles that u need with $argv ) and call the scirpt like this : system("./yourscirpt.php &"); // & will cause the script to go in the background, thus u will get control of your script immideately. I dont know how one can put things in the background on a win machine, but thats the idea. HTH gamin.

« previous php.general (#129754) next »