note 55438 added to function.exec
| From: | juha at kuhazor dot idlegames dot com | Date: | Wed, 03 Aug 2005 18:32:06 +0000 |
| Subject: | note 55438 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93020@lists.php.net to get a copy of this message | ||
This technique was post posted by someone else earlier, however it did not work for me. This works
with all Linux distros as long as path to your PHP processor is correct. The exec will return the
PID for the process.
<?
$pid=exec("/usr/local/bin/php run.php > /dev/null & echo \$!");
echo $pid;
?>
My run.php script is here, it is good for testing.
<?
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$starttime = getmicrotime();
$date=date("d/m/Y H:i",time());
echo "Started sleeping\n";
sleep(30);
$endtime = getmicrotime();
echo "Woke up\n";
echo "Slept ".round(($endtime-$starttime),2)."\n";
?>
----
Manual Page -- http://www.php.net/manual/en/function.exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55438
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55438&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55438&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55438&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55438&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55438&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55438&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55438&report=yes
Search -- http://master.php.net/manage/user-notes.php