2009-05-19 112 views
0

如何爲可能運行相當長時間的shell命令提供反饋?php長時間運行腳本

例如,我需要一個腳本,它汞克隆... ...然後在我的PHP我打個電話

exec('hg clone ...', $output, $return_value); 

,但我不會能夠得到的輸出命令實際上結束之前。它的文檔(http://www.php.net/manual/en/function.exec.php)中指出,

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. 

那就意味着我要改變我的命令,以類似的東西來

exec('hg clone 2>&1 $some_file', $output, $return_value); 

我需要連字符在命令後面,使它在後臺工作?並且我可以使用信息$ some_file向用戶提供反饋?

+0

看一看[另一個答案我給了一個類似的問題(http://stackoverflow.com/questions/工作正常838870 /調用外部的殼腳本從 - PHP-和發送-一些輸入到它/ 838915#838915) – soulmerge 2009-05-19 08:29:17

回答