[英]Set maximum execution time in MYSQL / PHP
I have an XML document that has around 48,000 children (~50MB). 我有一个XML文档,其中包含大约48,000个子级(〜50MB)。 I run an INSERT MYSQL query that makes new entries for each one of these children. 我运行INSERT MYSQL查询,为这些子项中的每个子项都创建新条目。 The problem is that it takes a lot of time due to its size. 问题是,由于其大小,它需要很多时间。 After it is executed I receive this 执行后,我收到这个
Fatal error: Maximum execution time of 60 seconds exceeded in /path/test.php on line 18
How do I set the Maximum execution time to be unlimited? 如何将最大执行时间设置为无限制?
Thanks 谢谢
You can make it by setting set_time_limit in you php code (set to 0 for no limit) 您可以通过在您的php代码中设置set_time_limit来实现(无限制地设置为0)
set_time_limit(0);
Or modifying the value of max_execution_time directly in your php.ini 或者直接在您的php.ini中修改max_execution_time的值
;;;;;;;;;;;;;;;;;;;
; 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()进行更改
ini_set('max_execution_time', 120); //120 seconds
but note that for this 3rd option : 但请注意,对于第三个选项:
max_execution_time max_execution_time
You can not change this setting with ini_set() when running in safe mode. 在安全模式下运行时,无法使用ini_set()更改此设置。 The only workaround is to turn off safe mode or by changing the time limit in the php.ini. 唯一的解决方法是关闭安全模式或通过更改php.ini中的时间限制。
Source www.php.net 来源www.php.net
Put this at the top of your script: 将其放在脚本的顶部:
ini_set('max_execution_time', 300);
That'll make it 5 minutes. 到5分钟。
您可以在应用程序的开头使用ini_set。
ini_set('max_execution_time', *number of seconds here*); //300 seconds = 5 minutes
You can Set maximum execution time in MYSQL / PHP. 您可以在MYSQL / PHP中设置最大执行时间。 it's so easy. 它是如此容易。
To set maximum execution time in single PHP file, place this code just after your first opening php tag. 要在单个PHP文件中设置最大执行时间,请在首次打开php标签之后放置此代码。
ini_set(‘max_execution_time’, 0)
To set maximum execution time in php.ini file. 在php.ini文件中设置最大执行时间。 You can set as per your require. 您可以根据需要进行设置。
max_execution_time=360 //360 seconds = 6 minutes
To set maximum execution time in htaccess file. 在htaccess文件中设置最大执行时间。
php_value max_execution_time 0
You can also read step by step here . 您也可以在这里逐步阅读 。
maximum execution time for Apache Web Server is 300 seconds (5 min), so if your script is very long you have to options Apache Web Server的最大执行时间为300秒(5分钟),因此,如果脚本很长,则必须选择
max_execution_time = (seconds)
for example to max_execution_time = 300
您的脚本最多可以在打开php.ini文件的5分钟内执行,并且可以将max_execution_time = (seconds)
更改为例如max_execution_time = 300
2.if you scripts need mor than 5 minutes you should first change Httpd.conf file (Apache config file) 2.如果脚本需要5分钟以上,则应首先更改Httpd.conf文件(Apache配置文件)
TimeOut (number of seconds you want)
and also in php.ini max_execution_time = (number of seconds you want)
以及在php.ini中, max_execution_time = (number of seconds you want)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.