12

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?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Harris Geo
  • 239
  • 2
  • 4
  • 14
  • Look at this answer, this will probably give you pointers to avoid this problem in the first place. http://stackoverflow.com/questions/911663/parsing-huge-xml-files-in-php This has various approaches. – skv Aug 15 '13 at 13:43

5 Answers5

11

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

Imane Fateh
  • 2,418
  • 3
  • 19
  • 23
0

Put this at the top of your script:

ini_set('max_execution_time', 300);

That'll make it 5 minutes.

Tdelang
  • 1,298
  • 2
  • 12
  • 20
0

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
Nick Shears
  • 1,103
  • 1
  • 13
  • 30
0

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.

Rinku
  • 83
  • 1
  • 1
  • 13
0

maximum execution time for Apache Web Server is 300 seconds (5 min), so if your script is very long you have to options

  1. your script can be executed on most 5 minutes open php.ini file and chanage max_execution_time = (seconds) for example to max_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)

user1324491
  • 147
  • 4