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
Giacomo1968
25.7k11 gold badges71 silver badges101 bronze badges
asked Oct 6, 2011 at 21:19
3
If you are using WAMP Go to :
Increase the max_execution_time
in php.ini
then go to
C:wampappsphpmyadmin3.4.10.1libraries
(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.
yarl
3,0871 gold badge22 silver badges28 bronze badges
answered Jul 4, 2013 at 9:33
Vipin DubeyVipin Dubey
1,3633 gold badges10 silver badges12 bronze badges
7
Xampp Users
- Go to
xamppphpMyAdmin
- Open config.inc.php
- Search for
$cfg['ExecTimeLimit'] = 300;
- Set a larger value or change to 0 for unlimited
- If not found add
$cfg['ExecTimeLimit'] = 900;
(or 0 for unlimited) - Save the file and restart the server
Important: setting the execution time limit to unlimited is not recommended.
answered Jan 10, 2014 at 18:21
TechnotronicTechnotronic
8,3343 gold badges40 silver badges53 bronze badges
4
At the beginning of your script you can add.
ini_set('MAX_EXECUTION_TIME', '-1');
reformed
4,45011 gold badges60 silver badges87 bronze badges
answered Oct 6, 2011 at 21:23
TulesTules
4,8952 gold badges27 silver badges29 bronze badges
5
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.
answered Apr 17, 2013 at 3:50
xiankaixiankai
2,7633 gold badges25 silver badges31 bronze badges
4
For Xampp Users
1. Go to C:xamppphpMyAdminlibraries
2. Open config.default.php
3. Search for $cfg['ExecTimeLimit'] = 300;
4. Change to the Value 300 to 0 or set a larger value
5. Save the file and restart the server
6. OR Set the ini_set('MAX_EXECUTION_TIME', '-1'); at the beginning of your script you can add.
answered Jun 16, 2019 at 7:27
Try something like the following in your script:
set_time_limit(1200);
answered Oct 6, 2011 at 21:22
Darth EgregiousDarth Egregious
17.7k3 gold badges31 silver badges54 bronze badges
2
go to the xampp/phpmyadmin/libraries/config.default.php
and make the following changes
from $cfg['ExecTimeLimit'] = ’300′;
to $cfg['ExecTimeLimit'] = ’0′;
maazza
6,95615 gold badges62 silver badges95 bronze badges
answered Feb 8, 2017 at 18:35
This is the the right answer:
go to
c:wampappsphpmyadmin3.4.10.1librariesconfig.default.php
find and set
$cfg['ExecTimeLimit'] = 0;
restart all services
and done.
CRUSADER
5,4863 gold badges28 silver badges62 bronze badges
answered Oct 9, 2013 at 15:40
llioorllioor
5,7344 gold badges36 silver badges43 bronze badges
0
For Local AppServ
Go to C:AppServwwwphpMyAdminlibrariesconfig.default.php
Find $cfg['ExecTimeLimit']
and set value to 0.
So it’ll look like
$cfg['ExecTimeLimit'] = 0;
davidkonrad
83.7k17 gold badges204 silver badges264 bronze badges
answered Jan 31, 2018 at 1:32
If xampp in localserver
Goto C:xamppphpMyAdminlibrariesconfig.default.php
//find $cfg['ExecTimeLimit']= 300;
//increase this value
$cfg['ExecTimeLimit'] = 3000;
answered Oct 4, 2021 at 6:39
So, after spending hours, this works for me (2023)
-
adding $cfg[‘ExecTimeLimit’] = 6000; into xampp/phpMyAdmin/config.inc.php
-
also I change $cfg[‘ExecTimeLimit’] = 6000; in xampp/phpMyAdmin/libraries/configdefault.php
answered Jun 9, 2022 at 19:06
PHP’s CLI’s default execution time is infinite.
This sets the maximum time in seconds a script is allowed to run
before it is terminated by the parser. This helps prevent poorly
written scripts from tying up the server. The default setting is 30.
When running PHP from the command line the default setting is 0.
http://gr.php.net/manual/en/info.configuration.php#ini.max-execution-time
Check if you’re running PHP in safe mode, because it ignores all time exec settings when on that.
answered Oct 6, 2011 at 21:35
MobMob
10.9k6 gold badges40 silver badges58 bronze badges
On Xampp, in php.ini you must check mysql.connect_timeout either. So, for example, change it to:
mysql.connect_timeout = 3600
That time will be always counted in seconds (so 1 hour in my example)
answered Nov 9, 2016 at 8:04
MAMP USERS
editing php.ini solves this — there is a line:
max_execution_time = 30 ; Maximum execution time of each script, in seconds
setting this to a higher value worked.
the file is in php/php5.6.25/conf/php.ini (obviousl you need to wet the file for the php version you are using — you can find this out from the MAMP preferences.
answered Dec 2, 2016 at 18:25
0
If you are on xampp and using phpMyadmin to import large sql files and you have increased max_execution time, max file upload limit and everything needed And If none of the above answers work for you come here
Go to your xampp folder, in my case here is the relative path to the file that I need to modify: C:xamppphpMyAdminlibrariesconfig.default.php
/**
* maximum execution time in seconds (0 for no limit)
*
* @global integer $cfg['ExecTimeLimit']
* by defautlt 300 is the value
* change it to 0 for unlimited
* time is seconds
* Line 709 for me
*/
$cfg['ExecTimeLimit'] = 0;
answered Nov 7, 2019 at 9:31
0
WAMP USERS:
1) Go to C:wampappsphpmyadmin
2) Open config.inc
3) Add $cfg[‘ExecTimeLimit’] = ’3600′; to the file.
4) Save the file and restart the server.
This file overwrites the php.ini and will work for you!
answered Dec 9, 2013 at 15:43
AsiAsi
3954 silver badges13 bronze badges
In my case, when I faced that error in Phpmyadmin, I tried MySQL-Front and import my DB successfully.
Note: You can still use the provided solutions under this question to solve your problem in Phpmyadmin.
answered Mar 5, 2014 at 9:41
Jamshid HashimiJamshid Hashimi
7,5902 gold badges28 silver badges27 bronze badges
1
If above answers will not work, try to check your code,,In my experience,having an infinite loop will also cause that problem.Check your else if statement.
answered Mar 30, 2015 at 4:58
In Codeignitor version 3.0.x the system/core/Codeigniter.php do not contain the time constraint as well as inserting
ini_set('MAX_EXECUTION_TIME', -1);
will not work since codeignitor will override that with its own function set_time_limit() .
So either you have to delete that function from codeignitor or simply you can insert
set_time_limit('1000');
in the beginning of the php file if you wanna change that to 1000 seconds.
Set the time to 0 (zero) if you want to run it as long as it want.
answered Oct 4, 2016 at 9:13
WenukaWenuka
8542 gold badges9 silver badges25 bronze badges
On wamp in my configuration where I have multiple phpmyadmins, the values in config files were overwritten in wamp/alias/phpmyadmin.conf
. I set up two lines there:
1. php_admin_value max_execution_time 3600
2. php_admin_value max_input_time 3600
… it finally worked!
J. M. Arnold
5,9683 gold badges20 silver badges38 bronze badges
answered Jan 5, 2021 at 0:06
For OpenServer
modulessystemhtmlopenserverphpmyadminlibrariesconfig.default.php
change
$cfg[‘ExecTimeLimit’] = 600
answered Nov 8, 2021 at 9:14
YurgenTMYurgenTM
711 silver badge5 bronze badges
You can set time limit:
ini_set('max_execution_time', 1000000000000000);
answered Sep 29, 2015 at 5:02
binhhoang18binhhoang18
5796 silver badges9 bronze badges
Есть скрипт который работает с API некоего сервера, выбирает много данных постепенными запросами, затем по каждому блоку данных выбирает дочерние данные и формирует массив в котором потом прозводится несколько операций.
Скрипт выполняется всегда 300 секунд, а времени нужно больше, хотя бы 10 минут. Попытки увеличения или снятия ограничения не привели ни к чему. Всё равно возникает ошибка
Fatal error: Maximum execution time of 300 seconds exceeded in C:OpenServerdomains……..
Вот что я пробовал делать:
В php.ini
max_execution_time = 86400
max_input_time = 86400
В начале скрипта:
set_time_limit(0);
ini_set('MAX_EXECUTION_TIME', 86400);
ini_set('MAX_EXECUTION_TIME', -1);
Работаю на CodeIgniter 2 под OpenServer 4.8.8 и php 5.4
На сайте с 28.08.2008
Offline
560
20 февраля 2016, 13:43
#1
На сайте с 16.06.2006
Offline
727
20 февраля 2016, 13:51
#2
Himiko:
Ищите в конфиге.
Himiko:
где еще поправить конфиги?
дык в том и проблема: в конфиге уже прописано:
MoMM:
max_execution_time = 30000
max_input_time = 30000
На сайте с 12.09.2011
Offline
365
20 февраля 2016, 13:58
#3
может сервер надо перезагрузить?
Мультур..
На сайте с 30.07.2014
Offline
59
20 февраля 2016, 14:01
#4
MoMM, в openserver конфиг правится по этому адресу:
C:OpenServeruserdataconfigPHP-5.4_php.ini
Есть еще один конфиг, который перезаписывается при каждом запуске. В него бесполезно вносить настройки. Он находится тут:
C:OpenServermodulesphpPHP-5.4php.ini
Вы в какой конфиг вносили правки?
На сайте с 16.06.2006
Offline
727
20 февраля 2016, 14:06
#5
Staid:
MoMM, в openserver конфиг правится по этому адресу:
C:OpenServeruserdataconfigPHP-5.4_php.ini
именно он и поправлен, только я 5.5 пользуюсь… мкасимальный размер файла нормально изменился на 2048, а вот время исполнения никак не хочет меняться и постоянно ошибка рочно через 300 сек, хотя прописывал уже и 30000 и 3600…
там 0 (без ограничений) работает в этом месте?
На сайте с 16.06.2006
Offline
727
20 февраля 2016, 14:07
#6
serjoo:
может сервер надо перезагрузить?
дык каждый раз перезагружаю
На сайте с 25.11.2006
Offline
1691
20 февраля 2016, 14:08
#7
там 0 (без ограничений) работает в этом месте?
Да.
Можете ещё попробовать в начало скрипта вставить:
set_time_limit(0);
или сколько хотите.
На сайте с 16.06.2006
Offline
727
20 февраля 2016, 14:12
#8
LEOnidUKG:
Можете ещё попробовать в начало скрипта вставить:
set_time_limit(0);
в начало PHP-5.4_php.ini ?
На сайте с 25.11.2006
Offline
1691
20 февраля 2016, 14:20
#9
MoMM:
в начало PHP-5.4_php.ini ?
Это в начало php файла.
<?php
set_time_limit(0);
На сайте с 30.07.2014
Offline
59
20 февраля 2016, 14:29
#10
MoMM, Советую такие большие файлы заливать через консоль openserver. Это проще простого.
Для этого открываем консоль:
Меню->Дополнительно->Консоль
Переходим в директорию mysql (проверьте свой путь и версию mysql)
cd C:OpenServermodulesdatabaseMySQL-5.5bin
Копируем базу в корень диска С. Далее вводим:
mysql -uroot test < C:test.sql
Эта команда подходит когда заранее создана база «test» и у пользователя root нет пароля.
1
Почему возникает ошибка
Ошибка maximum execution time появляется когда скрипт работает дольше, чем разрешено в настройках PHP:
<?php
// Устанавливаем максимальное время (1 секунда)
set_time_limit(1);
// Ждём 2 секунды и получаем ошибку
sleep(2);
Результатом работы этого скрипта будет ошибка:
Fatal error:
Maximum execution time of 1 second exceeded in
D:ProgramsOpenServerdomainstest.localindex.php on line 6
Почему скрипт чаще всего выполняется медленно:
- Слишком много вычислений в коде, которые сервер не может выполнить за разрешённое время
- Медленные SQL-запросы
- Медленные внешние запросы к другим сайтам/веб-сервисам
- Бесконечные циклы или рекурсия
Как исправить ошибку
В каждой ситуации решение индивидуальное. Часто проблему можно решить просто увеличив максимально разрешённое время работы скрипта (разрешено не на всех хостингах).
Увеличение времени работы скрипта в .htaccess (указывается в секундах):
php_value max_execution_time 300
В php.ini:
max_execution_time = 300;
Либо напрямую в PHP:
ini_set('max_execution_time', 300);
// Или так
set_time_limit(300);
У функции set_time_limit есть одна особенность — она начинает отсчёт времени работы скрипта с нуля.
Т.е. если время работы изначально было 10 секунд, а через 5 секунд был выполнен код set_time_limit(20);, то в итоге скрипт будет выполняться не более 25 секунд.
Отлов и обработка ошибки
Хоть ошибка и является фатальной, её появление можно отловить и обработать с помощью функции register_shutdown_function():
<?php
// Отключаем вывод текста ошибки на экран
ini_set('display_errors', 0);
register_shutdown_function(function() {
$e = error_get_last();
if($e and $e['type'] == 1) {
echo 'Фатальная ошибка!';
}
});
// Устанавливаем макс время - 1 секунду
set_time_limit(1);
// Ждём 2 секунды и получаем ошибку
sleep(2);
При выполнении этого кода на экран выведется сообщение Фатальная ошибка!.
Единственный нюанс — условие $e[‘type’] == 1 отработает для любых фатальных ошибок, а не только для Maximum execution time.
20 / 19 / 3 Регистрация: 20.06.2010 Сообщений: 621 |
|
1 |
|
18.09.2011, 01:03. Показов 14125. Ответов 9
Пытаюсь загрузить в Денвер БД ip стран *.csv около 11мб. Fatal error: Maximum execution time of 300 seconds exceeded in S:homelocalhostwwwToolsphpmyadminlibrariesstring_mb.lib.php on line 31 Подскажите как это сделать?
0 |
633 / 376 / 7 Регистрация: 25.05.2010 Сообщений: 1,372 |
|
18.09.2011, 01:09 |
2 |
Файл usrlocalphp5php.ini
0 |
20 / 19 / 3 Регистрация: 20.06.2010 Сообщений: 621 |
|
18.09.2011, 13:50 [ТС] |
3 |
Файл usrlocalphp5php.ini max_execution_time поднял с 30 до 500 Maximum execution time of 300 seconds Все те же 300 секунд.
0 |
633 / 376 / 7 Регистрация: 25.05.2010 Сообщений: 1,372 |
|
18.09.2011, 16:12 |
4 |
ICEBERG@
0 |
20 / 19 / 3 Регистрация: 20.06.2010 Сообщений: 621 |
|
18.09.2011, 17:12 [ТС] |
5 |
ICEBERG@ Естественно
0 |
xAtom 935 / 760 / 299 Регистрация: 09.12.2010 Сообщений: 1,346 Записей в блоге: 1 |
||||
18.09.2011, 23:37 |
6 |
|||
Подскажите как это сделать? В начале скрипта установи лимит времени.
0 |
ICEBERG@ 20 / 19 / 3 Регистрация: 20.06.2010 Сообщений: 621 |
||||||||
20.09.2011, 00:47 [ТС] |
7 |
|||||||
В начале скрипта установи лимит времени.
Какого еще скрипта? Я через phpMyAdmin загружаю. Добавлено через 22 часа 30 минут Только теперь другая проблема.
Помогите составить запрос страны по ip например 1.0.200.200
0 |
0 / 0 / 0 Регистрация: 27.09.2012 Сообщений: 12 |
|
08.04.2013, 14:00 |
8 |
Всем привет! В чем может быть проблема?
0 |
12 / 12 / 0 Регистрация: 04.04.2013 Сообщений: 59 |
|
08.04.2013, 14:02 |
9 |
Время исполнения запроса превышает 300 допустимых секунд, попробуйте увеличить время исполнения запросов в настройках php.ini. Перекодируйте файл в utf-8
0 |
0 / 0 / 0 Регистрация: 27.09.2012 Сообщений: 12 |
|
08.04.2013, 15:12 |
10 |
Да, в том то и дело, я кодировку файла тоже проверил он в UTF-8, все как положено. К тому же, если импортировать файл бОльшего размера (гораздо бОльшего) — то все проходит моментально. Просто была исходная таблица — она очень большая, в ней много не нужной информации. Я ее обработал, удалил лишнее, она сократилась более чем в 2.5 раза. И почему-то не хочет импортироваться. Хотя синтаксис точно ошибок не содержит. Потому что я аналогичным образом обработал другую таблицу — там все ОК. Если импортировать исходную таблицу — она проходит хорошо. Добавлено через 58 минут
0 |