Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用这篇文章的答案,但我想为 stderr 获取一个文件,为 stdout 获取一个文件。
这是我目前拥有的:
exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));
请提出一个适当的问题,因为我真的不知道你的意思。我将假设您想要分离输出和错误文件?
如果您想要 stdout 和 stderr 的单独文件,则需要删除重定向2>&1(将 stderr 重定向到 stdout)。
2>&1
exec(sprintf("%s > %s 2>%s & echo $! >> %s", $cmd, $outputfile, $errorfile, $pidfile));