It’s actually a combination of php and bash:
exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));
I don’t understand what 2>&1 & echo $! is there for?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
2>&1redirects stderr to stdout, and$!“Expands to the process ID of the most recently executed background (asynchronous) command”.So, here’s what happens:
$cmdto a file named$outputfile. If you didn’t do2>&1, you wouldn’t be able to read the stderr output in the file.&means that process runs in the background.$cmd(obtained through$!) to the end of$pidfile.