Re: Exec Script in the background, don't wait till it finishes
| From: | Daniel Brown | Date: | Fri, 14 Jan 2011 18:40:18 +0000 |
| Subject: | Re: Exec Script in the background, don't wait till it finishes | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310768@lists.php.net to get a copy of this message | ||
On Fri, Jan 14, 2011 at 13:28, Kai Renz <writemecas@googlemail.com> wrote:
(Putting this back on the list. Please use Reply-All.)
> @Daniel:
> Yeh i tried sending it to the background, this works but still it does
> wait for the other script to finish.
It shouldn't. In fact, just to see if I somehow completely forgot
how things worked, I just mocked up the following and verified it
worked perfectly:
<?php
// 1.php
php ./2.php >> /dev/null 2>&1 &;
echo 'I will now terminate, while the other script continues.'.PHP_EOL;
?>
<?php
// 2.php
while (1) {
file_put_contents('./123-whee.txt','I\'m still
running!'.PHP_EOL,FILE_APPEND);
}
?>
dan@blackbox:~$ php 1.php
I will now terminate, while the other script continues.
dan@blackbox:~$ tail -f ./123-whee.txt
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
I'm still running!
^C
dan@blackbox:~$ ps -ef | grep -i php
dan 29428 1 34 13:37 pts/166 00:00:24 php ./2.php
dan 29491 28729 0 13:38 pts/166 00:00:00 grep --color=auto -i php
--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/