我有一个脚本,其中一部分运行命令行进程,如果直接在服务器上运行(Windows Server 2008),则只需不到一秒钟。
通过exec()
,passthru()
或system()
运行时,它需要30秒,但输出确认程序本身需要0.5秒,就像直接在服务器上运行一样。
Sample 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 :(得分:0)
修改强>
试试这个:
Proc_Close (Proc_Open ("path\to\software --field=1 &", Array (), $field));
之前的回答适用于评论:
我总是使用:
system('echo . | path\to\software path\to\file ect...');
它开始很快。