It's actually a combination of php and bash:
exec(sprintf("%s > %s 2>&1 & echo $! >> %s",开发者_StackOverflow社区 $cmd, $outputfile, $pidfile));
I don't understand what 2>&1 & echo $! is there for?
2>&1 redirects stderr to stdout, and $! "Expands to the process ID of the most recently executed background (asynchronous) command".
So, here's what happens:
- You send both stderr and stdout of
$cmdto a file named$outputfile. If you didn't do2>&1, you wouldn't be able to read the stderr output in the file. - The following
&means that process runs in the background. - Then you append the PID of
$cmd(obtained through$!) to the end of$pidfile.
加载中,请稍侯......
精彩评论