I have an XML document that has around 48,000 children (~50MB). I run an INSERT MYSQL query that makes new entries for each one of these children. 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)
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
Put this at the top of your script:
ini_set('max_execution_time', 300);
That'll make it 5 minutes.
You can use the ini_set at the start of your application.
ini_set('max_execution_time', *number of seconds here*); //300 seconds = 5 minutes
You can Set maximum execution time in 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.
ini_set(‘max_execution_time’, 0)
To set maximum execution time in php.ini file. You can set as per your require.
max_execution_time=360 //360 seconds = 6 minutes
To set maximum execution time in htaccess file.
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
- your script can be executed on most 5 minutes
open php.ini file and chanage
max_execution_time = (seconds)
for example tomax_execution_time = 300
2.if you scripts need mor than 5 minutes you should first change Httpd.conf file (Apache config file)
TimeOut (number of seconds you want)
and also in php.ini max_execution_time = (number of seconds you want)
来源:https://stackoverflow.com/questions/18253934/set-maximum-execution-time-in-mysql-php