Re: [PHP] How to launch a background task from a web page
- From: daniel.brown@xxxxxxxxxxxx ("Daniel P. Brown")
- Date: Thu, 30 Oct 2008 11:50:43 -0500
On Thu, Oct 30, 2008 at 11:38 AM, Tony Marston
<tony@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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?
There are a number of ways to do this, including (1) setting up
the process to be created as a cron job[1], run by cron independently;
(2) using a combination of exec('command &')[2] and
ignore_user_abort(1)[3] functions to force a command to daemonize and
continue running until completes; (3) work out a routine to use
process control[4]. All of these presume a *NIX system, of course.
Key:
1: http://www.underwaterdesign.com/2006/06/php_create_a_cron_job_with_php.php
2: http://php.net/function.exec
3: http://php.net/ignore-user-abort
4: http://www.php.net/manual/en/ref.pcntl.php
--
</Daniel P. Brown>
http://www.parasane.net/
daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx
Ask me about our current hosting/dedicated server deals!
.
- References:
- How to launch a background task from a web page
- From: "Tony Marston"
- How to launch a background task from a web page
- Prev by Date: Re: [PHP] How to launch a background task from a web page
- Next by Date: Re: [PHP] Recursive Directory Listing
- Previous by thread: Re: [PHP] How to launch a background task from a web page
- Next by thread: RE: [PHP] How to launch a background task from a web page
- Index(es):
Relevant Pages
|