标签: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 &‘);
标签:code nohup dev 后台运行 程序 color log 启动 details
原文地址:https://www.cnblogs.com/djwhome/p/9183234.html