Re: Exec Script in the background, don't wait till it finishes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 14, 2011 at 13:28, Kai Renz <writemecas@xxxxxxxxxxxxxx> 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/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux