Possible Duplicate:
Call another PHP script and return control to user before the other script completes
I need to run a PHP script from another PHP script asynchronously.
Script 1
<?php
echo "Entering main script 1";
system("php script2.php");
echo "Exiting main script 1";
?>
Script 2
<?php
echo "Entering script 2";
sleep(10);
echo "Exiting script 2";
?>
In script 1, I use system() method to run script2.php. I dont want script 1 to wait for script 2 to complete its execution. How to make it asynchronous? Is there any other method to run a PHP script without using system() function? Please help me. Thanks.
Add an &
to the end of the command-line to make the process run in the background on the vast majority of shells. i.e.:
Script 1
<?php
echo "Entering main script 1";
system("php script2.php &");
echo "Exiting main script 1";
?>
精彩评论