學習源頭:
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 &');