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 usage of the above mentioned system command. What does '2>&1 &' stand for ? I want to dump the process details to a file how do I do that ?
Thank you very much.
2>&1 redirects «stderr» to «stdout», & at the end makes the command run in background.
To make it complete it should be
«command» 2>&1 > /tmp/somefile.log &
Without redirecting «stdout» to a file (or to /dev/null) running in background from system() doesn't make much sense, as your command would get killed as soon as PHP terminates (e.g. reaching time limit).
From system() manual:
Note: If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With