PHP set_time_limit not working for exec


PHP set_time_limit not working for exec

我在PHP (v5.4.13)中有一个奇怪的时间限制管理行为。

我在php.ini中设置max_execution_time30,在我的脚本中我调用:

set_time_limit(1000) ;

并确保它已设置,我调用:

error_log (ini_get('max_execution_time'));

返回1000。但是现在如果我用

来调用程序
exec("foobar.exe") ;

(一个很长的程序,运行大约需要5分钟),脚本停止并在日志中显示错误:

PHP Fatal error:  Maximum execution time of 120 seconds exceeded

我的问题是为什么这个脚本在120秒后停止?什么好主意吗?

检查你的php.ini是否打开了Safe_Mode。如果是,max_execution_time无效

好的,我找到问题了。

那是愚蠢的:set_time_limit(1000);我的exec("…");我调用了几个函数。深入研究这些函数,会让你大吃一惊!

set_time_limit (120);

谢谢大家的帮助!