Re: Asynchronous PHP Execution
| From: | Richard Heyes | Date: | Sun, 06 Jul 2008 09:47:08 +0000 |
| Subject: | Re: Asynchronous PHP Execution | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276329@lists.php.net to get a copy of this message | ||
Waynn Lue wrote:
I think so.worked, after some fiddling. Just as a side note, does it execute from the current directory of the file?and exec/shell (but that doesn't seem to be asynchronous), but neither seems optimal.It can be if you redirect the output streams and put an ampersand after it: <?php exec('sleep 5 > /dev/null 2>/dev/null &'); echo 'Script ended'; ?> This tiny sample should end immediately, and the sleep command should run on regardless. Thanks so much for the suggestion, that's what I ended up doing and it
Previously, I tried calling exec('php scripts/foo.php'), but it seemed like there was some weird interaction between different required files. E.g., this was the layout: orig.php scripts/foo.php incl.php orig.php had the exec line, and foo.php had require_once(../incl.php). But it seemed like the exec call caused foo.php to execute from the scripts directory while the require_once caused incl.php to also execute from the scripts directory. How does php determine what the working directory is?I believe it's the directory of the original script. So if you had: require_once('scripts/foo.php'); ...in orig.php, that would be correct. -- Richard Heyes Employ me: http://www.phpguru.org/cv