Re: How to launch a background task from a web page
| From: | Richard Heyes | Date: | Thu, 30 Oct 2008 16:46:03 +0000 |
| Subject: | Re: How to launch a background task from a web page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-282637@lists.php.net to get a copy of this message | ||
> 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)