码迷,mamicode.com
首页 > Web开发 > 详细

php system()

时间:2018-06-14 18:22:06      阅读:484      评论:0      收藏:0      [点我收藏+]

标签:code   nohup   dev   后台运行   程序   color   log   启动   details   

学习源头:

https://blog.csdn.net/ltx06/article/details/53992905

 

system(“nohup ./test.py $s &”);

这个不会在后台运行,php会一直挂起直到test.py结束。

system(“nohup ./test.py $s >>log.txt &”);

这样写才能在后台运行因为system函数启动一个程序并希望保持在后台运行,

必须确保该程序的输出被重定向到一个文件或者其它输出流去,否则PHP 会在程序执行结束前挂起。

比如:

1、 system(“nohup ./test.py $s >>/tmp/output.txt &”);

2、 system(“nohup ./test.py $s > /dev/null 2>&1 &”); 

       (2>&1是错误输出转到标准输出,想读错误输出就加2>&1,不加读不到错误)

 

   或 system(“nohup ./test.py $s > /dev/null &”);

 

 

system(‘/usr/bin/nohup ‘.config(‘iqiyi.phppath‘).‘php ../artisan expon ‘." $datas ".‘>> ‘.config(‘iqiyi.logpath‘).date(‘Y‘).‘log.txt &‘);

 

 

 

php system()

标签:code   nohup   dev   后台运行   程序   color   log   启动   details   

原文地址:https://www.cnblogs.com/djwhome/p/9183234.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!