Dump php command output to file

In the php system command we use the following

system("ffmpeg -i test.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output_file.flv 2>&1 &"). 

Please explain the use of the above system command. What is' 2> & 1 & stand? I want to dump process details to a file, how to do this?

Many thanks.

+3
source share
4 answers

2>&1redirects " stderr" to " stdout" , &at the end makes the command run in background .

To do this, he must be

«command» 2>&1 > /tmp/somefile.log &

"stdout" ( /dev/null), system() , PHP (, ).

system() :

. , , . PHP .

+10

2 > & 1 (2) (1).

, .

stderr stdout , .

stderr , 2 > 1 2 >

(: 2 > /home/user/output.mpg)

+1

UNIX : stdout stderr. ul > stdout ( 1) . "2 > " stderr ( 2) , "& 1", 1 ( ). php , script, , , .

. , .

+1

If you want to write to a file via PHP, you can also use [exec()][1]or [passthru()][2], which have options to return all the contents from the command. system()will only return the last line.

0
source

Source: https://habr.com/ru/post/1706745/


All Articles