Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Maximum execution time of 300 seconds exceeded

I keep getting this PHP error:

Fatal error: Maximum execution time of 300 seconds exceeded

I have tried setting my max_execution_time and my max_input_time settings in php.ini (both apache and cli) to 0, -1 and 4000 seconds each.

And i still get the error saying:

Fatal error: Maximum execution time of 300 seconds exceeded

As well my script runs over 300 seconds before i get this message

I am running the script through command line.

I also checked my phpinfo() so see which php.ini I am using.

Even more interesting I have tried setting max_execution_time and max_input_time settings to 5 second and my script will run way beyond 5 seconds before I get the:

Fatal error: Maximum execution time of 300 seconds exceeded

like image 909
dez Avatar asked Oct 06 '11 21:10

dez


4 Answers

If you are using WAMP Go to :

Increase the max_execution_time in php.ini then go to

C:\wamp\apps\phpmyadmin3.4.10.1\libraries (change path according to your installation)

open config.default.php and change value for $cfg['ExecTimeLimit'] to 0:

$cfg['ExecTimeLimit'] = 0;

This will resolve the issue for PhpMyAdmin imports.

like image 56
Vipin Dubey Avatar answered Nov 12 '22 04:11

Vipin Dubey


Xampp Users

  1. Go to xampp\phpMyAdmin\
  2. Open config.inc.php
  3. Search for $cfg['ExecTimeLimit'] = 300;
  4. Set a larger value or change to 0 for unlimited
  5. If not found add $cfg['ExecTimeLimit'] = 900; (or 0 for unlimited)
  6. Save the file and restart the server

Important: setting the execution time limit to unlimited is not recommended.

like image 35
Technotronic Avatar answered Nov 12 '22 06:11

Technotronic


At the beginning of your script you can add.

ini_set('MAX_EXECUTION_TIME', '-1');
like image 74
Tules Avatar answered Nov 12 '22 05:11

Tules


I encountered a similar situation, and it turns out that Codeigniter (the PHP framework I was using) actually sets its own time limit:

In system/core/Codeigniter.php, line 106 in version 2.1.3 the following appears:

if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
    @set_time_limit(300);
}

As there was no other way to avoid changing the core file, I removed it so as to allow configuration through php.ini, as well as give the infinite maximum execution time for a CLI request.

I recommend recording this change somewhere in the case of future CI version upgrades however.

like image 25
xiankai Avatar answered Nov 12 '22 04:11

xiankai