2016-08-02 38 views
0

我有一個腳本,其中的一部分運行一個命令行過程,如果直接在服務器上運行(Windows Server 2008),則需要不到一秒的時間。PHP exec()花費太長時間來初始化,是否有其他選擇?

當運行它通過exec(),passthru()system()它需要超過30秒,但輸出確認程序本身需要0.5秒,因爲它直接在服務器上運行。

樣品Exec的

shell_exec(path\to\software path\to\file -sqldata "SELECT * FROM table WHERE this = that" -f "path\to\output" -c path\to\config -e PDF -ec proof -o "Proof") 

樣品響應

Inspire Designer Console 10.0 SP1 Production System 
Net license (192.168.20.102) 
License is valid till 2017-06-30. 
Opening workflow path\to\file 2.8.2016 9:01:08.412. 
Status message 0881:Reading config file path\to\config. 
Status message 0884:Running module Proof. 
Status message 0243:ODBC Data Input: Executing: SELECT * FROM table WHERE this = that 
Status message 0246:ODBC Data Input: Reading completed with 1 records (data) 
Status message 0045:Data opened (duration 0:00:00.015, records 1). 
Status message 0045:Data opened (duration 0:00:00.000, records 1). 
Status message 0645:Job started (engine PDF, range 1-end, copies 1, file path\to\output). 
Warning 0062:Page Page 1 uses output name Main with different size. Using bigger. 
Warning 5505:PDF: Optimization for fast web view enabled. The spooling time can grow significantly. 
Status message 5506:PDF: Linearization in progress. 
Status message 0003:Job finished (duration 0:00:00.234, sheets 1, sheets/min 256.41). 
Complete run time: 0:00:00.483. 

有沒有一種可行的替代方案,或者改善exec()函數的「初始化」的時間來改善我們的網站加載時間的方式?

回答

0

編輯:

試試這個:

Proc_Close (Proc_Open ("path\to\software --field=1 &", Array(), $field)); 

以前它適用評論答案:

我總是用:

system('echo . | path\to\software path\to\file ect...'); 

它啓動速度快。

+0

爲什麼多餘的echo會提高性能? –

+0

我明白這個問題不是免費的處理,但在PHP腳本中不會退出 –

+0

不幸的是,解決方案建議不會正常運行我們的軟件 – TomK89