note 38451 deleted from function.exec by danbrown
| From: | danbrown@php.net | Date: | Sun, 04 Jan 2009 16:32:19 +0000 |
| Subject: | note 38451 deleted from function.exec by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-148812@lists.php.net to get a copy of this message | ||
Note Submitter: alerque.com, look for contact info
----
In order to execute a command have have it not hang your php script while it runs, the program you
run must not output back to php. To do this, redirect both stdout and stderr to /dev/null, then
background it.
> /dev/null 2>&1 &
In order to execute a command and have it spawned off as another process that is not dependent on
the apache thread to keep running (will not die if somebody cancels the page) run this:
exec('bash -c "exec nohup setsid your_command > /dev/null 2>&1
&"');