php system()


學習源頭:

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 &');

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM