Home > Backend Development > PHP Tutorial > PHP executes shell without blocking method shell if Royal Dutch Shell Group adb shell

PHP executes shell without blocking method shell if Royal Dutch Shell Group adb shell

WBOY
Release: 2016-07-29 08:52:58
Original
1225 people have browsed it

Everyone knows that the methods of executing system commands in PHP are:
system() prints and returns the last line of shell results.
exec() does not output results and returns the last line of shell results. All results can be saved in a returned array.
passthru() only calls the command and outputs the command's running results directly to the standard output device as is.

These methods will wait for the command to be executed before continuing to execute subsequent programs
Without blocking, you can write the command output to a recycle bin file of the system, so that the program will not block
For example:

<code>shell_<span>exec</span>(<span>"/use/local/php/bin/php /www/t.php  > /dev/null 2>&1 &"</span>);</code>
Copy after login

You may often see in shell: >/dev/null 2>&1

The result of the command can be defined in the form of %> The output

/dev/null represents an empty device file

Represents where to redirect, for example: echo “123” > /home/123.txt
1 represents stdout standard output, the system default value is 1, so ">/dev/null" is equivalent to "1>/dev/null"
2 represents stderr standard error
& means equal to, 2>&1, indicating that the output redirection of 2 is equivalent to 1

Then the sentence of the title of this article:
1>/dev/null first means that the standard output is redirected to an empty device file, that is, no information is output to the terminal. To put it bluntly, no information is displayed.
2>&1 Next, standard error output redirection is equivalent to standard output, because standard output has been redirected to an empty device file before, so standard error output is also redirected to an empty device file.

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the method of executing PHP shell without blocking, including shell content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template