Re: run php in background "atomic" - wild trick

From: Date: Wed, 29 Nov 2000 11:07:43 +0000
Subject: Re: run php in background "atomic" - wild trick
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27799@lists.php.net to get a copy of this message
Hi mailing_list! On Wed, 29 Nov 2000, mailing_list@gmx.at wrote: > hi! > > If a specific php-page is requested, there should start another process > (php or perl - but php prefered), that takes about half a minute to finish! > How would I make this call without letting the client wait half a minute! > And is it possible, if anotherone (client2) requests this page a second > after client1, that the now started process2 waits for the finishing of > process1??? I've done it in an hackish way, which sometimes worked, sometime didn't namely, if you don't expect any output from the program being spawned, register a function with register_shutdown_function() and execute it there. Don't forget to ignore_user_abort() and set_time_limit() higher. example: function SayHello2theCustomer () { /*n.b. : joke */ if (strstr($USER_AGENT,'MSIE')) { system ("/sbin/jolt2 $REMOTE_ADDR"); } else { mail ($mail,"Thank you","Thank you for buying phpBaz produkt"); } } // your cool script here set_time_limit(0); ignore_user_abort(1); register_shutdown_function ("SayHello2theCustomer"); cool, eh? :) cheers, -- teodor

« previous php.general (#27799) next »