Re: Spawning a background process

From: Date: Tue, 05 Nov 2002 11:52:06 +0000
Subject: Re: Spawning a background process
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-122758@lists.php.net to get a copy of this message
> Basically, my question is.. how do I do this? I am actually (for > various .. and probably stupid... reasons) trying to spawn a php > process to run in the background. This process I know will take a > couple of hours to run (mailing list stuff). I have been playing > around with system to try to get it to run in the background but I > can't seem to work out how to do it. A process which generates output (or can generate output) will make the system or exec call in blocking. That means that the PHP script will wait until your script is finished. This can be simply fooled by adding "> /dev/null" to your commandline (if you're running on a *nix based machine of course). I have a simple background process, which forks itself and then immediately returns (only the parent process, the child keeps on running). Even then the exec function was blocking, until I added "> /dev/null" to the commandline. If you're background process doesn't spawn it's own child, I think you'll have to add an ampersand (&) also, to make the program run in background. HTH Erwin

« previous php.general (#122758) next »