加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

将php系统命令输出转储到文件

发布时间:2020-12-13 21:59:35 所属栏目:PHP教程 来源:网络整理
导读:在php系统命令中,我们使用以下内容 system("ffmpeg -i test.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv output_file.flv 21 "). 请解释上述系统命令的用法.什么是’2 1’代表 ?我想将进程详细信息转储到文件中,我该怎么做? 非常感谢你. 解决方
在php系统命令中,我们使用以下内容

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

请解释上述系统命令的用法.什么是’2>& 1&’代表 ?我想将进程详细信息转储到文件中,我该怎么做?

非常感谢你.

解决方法

2>& 1重定向 ?stderr?至 ?stdout?,&最后使命令在 background运行.

要完成它应该是

?command? 2>&1 > /tmp/somefile.log &

没有将?stdout?重定向到从system()后台运行的文件(或/dev/null)没有多大意义,因为一旦PHP终止(例如达到时间限制),你的命令就会被杀死.

system()手册:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读