system("nohup php index.php >/dev/null &");
The Nohup command will open a new process to perform the subsequent PHP task
Here is a place to pay attention to, this paragraph >/dev/null &is indispensable, >/dev/null means that PHP execution results are immediately returned to NULL, if not added, the call to the command PHP will wait for the system to invoke the results of the PHP page, not a multi-process effect,& Is the mark of the end of the Nohup command.
Example:
There is a create.php file with the following contents:
foreach( $list as$v)
{
system("Nohup php single.php?key={$v}>/dev/null & ");
}
$list can be a collection of data taken out of the database that needs to be looped, and the single.php that is called with the Nohup command has its own content
In the terminal input command: nohup PHP create.php &
Then there will be more than one single.php process in the execution, under normal circumstances create.php will be an infinite loop of code, so as to ensure that create.php can always run in the background, so the process of heavy single.php needs to be discharged
This article is from the "PHP Related Technology blog" blog, please be sure to keep this source http://junstar.blog.51cto.com/4551565/1676655
Multi-process PHP using the nohup command under a Linux server