Multi-process PHP using the nohup command under a Linux server

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.