我有一个包含大约 48,000 个孩子 (~50MB) 的 XML 文档。我运行一个 INSERT MYSQL 查询,为这些孩子中的每一个创建新条目。问题是由于它的大小,它需要很多时间。执行后我收到这个
Fatal error: Maximum execution time of 60 seconds exceeded in /path/test.php on line 18
如何将最大执行时间设置为无限制?
谢谢
You can make it by setting set_time_limit in you php code (set to 0 for no limit)
set_time_limit(0);
Or modifying the value of max_execution_time directly in your php.ini
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 120
Or changing it with ini_set()
ini_set('max_execution_time', 120); //120 seconds
but note that for this 3rd option :
max_execution_time
You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini.
Source www.php.net
将其放在脚本的顶部:
ini_set('max_execution_time', 300);
这样5分钟就可以了。
您可以在应用程序开始时使用 ini_set。
ini_set('max_execution_time', *number of seconds here*); //300 seconds = 5 minutes
您可以在 MYSQL/PHP 中设置最大执行时间。它是如此容易。
要在单个 PHP 文件中设置最长执行时间,请将此代码放在第一个打开的 php 标记之后。
ini_set(‘max_execution_time’, 0)
在 php.ini 文件中设置最大执行时间。您可以根据自己的需要进行设置。
max_execution_time=360 //360 seconds = 6 minutes
在 htaccess 文件中设置最大执行时间。
php_value max_execution_time 0
您也可以在此处逐步阅读。
Apache Web 服务器的最大执行时间是 300 秒(5 分钟),所以如果你的脚本很长,你必须选择
max_execution_time = (seconds)
例如max_execution_time = 300
2.如果您的脚本需要超过 5 分钟,您应该首先更改 Httpd.conf 文件(Apache 配置文件)
TimeOut (number of seconds you want)
以及在 php.ini 中max_execution_time = (number of seconds you want)