Re: How to launch a background task from a web page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I have some long running scripts which I need to launch from a web page and
> have them run in the background, but which should not cause the web page to
> wait until the script finishes. Reading the manual on the backtick and
> exec() operators seems to imply that the PHP function will be suspended
> until the script finishes, which is not what I want. Is this possible in
> PHP?

You need to redirect all output (I'm assuming you're on *nix), ie
STDEOUT and STDERR. For example:

$cmd = 'sleep 5';
exec("{$cmd} > /dev/null 2>&1");

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated October 25th)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux