致命错误:超过300秒的最大执行时间。

时间:2022-08-12 15:47:52

I keep getting this PHP error:

我一直得到这个PHP错误

Fatal error: Maximum execution time of 300 seconds exceeded

致命错误:超过300秒的最大执行时间。

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.

我尝试在php中设置max_execution_time和max_input_time设置。ini (apache和cli)分别为0、-1和4000秒。

And i still get the error saying:

我还是会犯这样的错误:

Fatal error: Maximum execution time of 300 seconds exceeded

致命错误:超过300秒的最大执行时间。

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

我的脚本在收到此消息之前运行了300秒。

I am running the script through command line.

我正在通过命令行运行脚本。

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

我还检查了phpinfo(),查看哪个php。ini我使用。

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:

更有趣的是,我尝试将max_execution_time和max_input_time设置设置为5秒,我的脚本将在我获得:

Fatal error: Maximum execution time of 300 seconds exceeded

致命错误:超过300秒的最大执行时间。

16 个解决方案

#1


49  

At the beginning of your script you can add.

在您的脚本开始时,您可以添加。

ini_set('MAX_EXECUTION_TIME', -1);

#2


69  

If you are using WAMP Go to :

如果你使用的是WAMP:

Increase the max_execution_time in php.ini then go to

在php中增加max_execution_time。ini然后去

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

C:\wamp\apps\phpmyadmin3.4.10.1\libraries(根据您的安装更改路径)

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

打开config.default.php并将$cfg的更改值('ExecTimeLimit')改为0:

$cfg['ExecTimeLimit'] = 0;

This will resolve the issue for PhpMyAdmin imports.

这将解决PhpMyAdmin导入的问题。

#3


40  

Xampp Users

Xampp用户

  1. Go to xampp\phpMyAdmin\
  2. xampp \ phpMyAdmin \
  3. Open config.inc.php
  4. 打开config.inc.php
  5. Search for $cfg['ExecTimeLimit'] = 300;
  6. 搜索$cfg['ExecTimeLimit'] = 300;
  7. Change to 0 for unlimited or put a larger value
  8. 将值改为0,或者设置更大的值。
  9. If not found add $cfg['ExecTimeLimit'] = 0; (or a larger value)
  10. 如果没有发现增加$cfg['ExecTimeLimit'] = 0;(或更大的值)
  11. Save the file and restart the server
  12. 保存文件并重新启动服务器。

#4


23  

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

我遇到了类似的情况,我发现Codeigniter(我正在使用的PHP框架)实际上设置了自己的时间限制:

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

在系统/核心/ Codeigniter。在版本2.1.3中第106行,如下所示:

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.

由于没有其他方法可以避免更改核心文件,所以我删除了它以便允许通过php进行配置。ini,以及为CLI请求提供无限的最大执行时间。

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

但是,我建议在将来的CI版本升级的情况下记录这一变化。

#5


9  

Try something like the following in your script:

在你的脚本中尝试如下内容:

set_time_limit(1200);

#6


6  

This is the the right answer:

这是正确答案:

go to

c:\wamp\apps\phpmyadmin3.4.10.1\libraries\config.default.php

find and set

查找和设置

$cfg['ExecTimeLimit'] = 0;

restart all services and done.

重新启动所有服务并完成。

#7


2  

go to the xampp/phpmyadmin/libraries/config.default.php

去xampp / phpmyadmin /图书馆/ config.default.php

and make the following changes

并进行以下更改。

from  $cfg['ExecTimeLimit'] = ’300′;
to  $cfg['ExecTimeLimit'] = ’0′;

#8


1  

PHP's CLI's default execution time is infinite.

PHP的CLI的默认执行时间是无限的。

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.

这将设置一个脚本在被解析器终止之前允许运行的最长时间。这有助于防止编写糟糕的脚本将服务器捆绑在一起。默认设置为30。从命令行运行PHP时,默认设置为0。

http://gr.php.net/manual/en/info.configuration.php#ini.max-execution-time

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.

检查您是否在安全模式下运行PHP,因为它忽略了所有的时间exec设置。

#9


0  

WAMP USERS:

里面的用户:

1) Go to C:\wamp\apps\phpmyadmin

1)转到C:\ wamp \程序\ phpmyadmin

2) Open config.inc

2)打开config.inc

3) Add $cfg['ExecTimeLimit'] = ’3600′; to the file.

3)添加$ cfg[' ExecTimeLimit ']= ' 3600′;到文件。

4) Save the file and restart the server.

4)保存文件并重新启动服务器。

This file overwrites the php.ini and will work for you!

这个文件覆盖了php。我会为你工作的!

#10


0  

In my case, when I faced that error in Phpmyadmin, I tried MySQL-Front and import my DB successfully.

在我的例子中,当我在Phpmyadmin中遇到这个错误时,我尝试了MySQL-Front并成功导入了我的DB。

Note: You can still use the provided solutions under this question to solve your problem in Phpmyadmin.

注意:在这个问题下,您仍然可以使用提供的解决方案来解决Phpmyadmin中的问题。

#11


0  

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.

如果上面的答案不能工作,试着检查你的代码,根据我的经验,有一个无限循环也会导致这个问题。检查你的else if语句。

#12


0  

In Codeignitor version 3.0.x the system/core/Codeigniter.php do not contain the time constraint as well as inserting

在Codeignitor 3.0版。x系统/核心/ Codeigniter。php不包含时间约束和插入。

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

由于codeignitor将使用它自己的函数set_time_limit()来覆盖它,因此将不起作用。因此,要么你必须从codeignitor中删除该函数,或者简单地插入。

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.

在php文件的开头,如果你想把它改成1000秒。将时间设置为0(0),如果您想运行它,只要它需要。

#13


0  

On Xampp, in php.ini you must check mysql.connect_timeout either. So, for example, change it to:

Xampp,在php中。你必须检查mysql。connect_timeout。例如,把它改成:

mysql.connect_timeout = 3600

That time will be always counted in seconds (so 1 hour in my example)

那个时间总是以秒为单位计算(在我的例子中是1小时)

#14


0  

MAMP USERS editing php.ini solves this - there is a line:

MAMP用户编辑php。ini解决了这个问题,有一行:

max_execution_time = 30 ; Maximum execution time of each script, in seconds

max_execution_time = 30;每个脚本的最大执行时间,以秒为单位。

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.

该文件在php/php5.6.25/conf/php中。ini (obviousl需要为您正在使用的php版本润湿文件),您可以从MAMP首选项中找到它。

#15


0  

For Local AppServ

为当地AppServ

Go to C:\AppServ\www\phpMyAdmin\libraries\config.default.php

为其提供AppServ \拥有到C:\ www \ phpMyAdmin \图书馆\ config.default.php

Find $cfg['ExecTimeLimit'] and set value to 0.

找到$cfg['ExecTimeLimit'],并将值设为0。

So it'll look like

所以它会是什么样子

$cfg['ExecTimeLimit'] = 0;

#16


-1  

You can set time limit:

你可以设定时间限制:

ini_set('max_execution_time', 1000000000000000);

#1


49  

At the beginning of your script you can add.

在您的脚本开始时,您可以添加。

ini_set('MAX_EXECUTION_TIME', -1);

#2


69  

If you are using WAMP Go to :

如果你使用的是WAMP:

Increase the max_execution_time in php.ini then go to

在php中增加max_execution_time。ini然后去

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

C:\wamp\apps\phpmyadmin3.4.10.1\libraries(根据您的安装更改路径)

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

打开config.default.php并将$cfg的更改值('ExecTimeLimit')改为0:

$cfg['ExecTimeLimit'] = 0;

This will resolve the issue for PhpMyAdmin imports.

这将解决PhpMyAdmin导入的问题。

#3


40  

Xampp Users

Xampp用户

  1. Go to xampp\phpMyAdmin\
  2. xampp \ phpMyAdmin \
  3. Open config.inc.php
  4. 打开config.inc.php
  5. Search for $cfg['ExecTimeLimit'] = 300;
  6. 搜索$cfg['ExecTimeLimit'] = 300;
  7. Change to 0 for unlimited or put a larger value
  8. 将值改为0,或者设置更大的值。
  9. If not found add $cfg['ExecTimeLimit'] = 0; (or a larger value)
  10. 如果没有发现增加$cfg['ExecTimeLimit'] = 0;(或更大的值)
  11. Save the file and restart the server
  12. 保存文件并重新启动服务器。

#4


23  

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

我遇到了类似的情况,我发现Codeigniter(我正在使用的PHP框架)实际上设置了自己的时间限制:

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

在系统/核心/ Codeigniter。在版本2.1.3中第106行,如下所示:

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.

由于没有其他方法可以避免更改核心文件,所以我删除了它以便允许通过php进行配置。ini,以及为CLI请求提供无限的最大执行时间。

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

但是,我建议在将来的CI版本升级的情况下记录这一变化。

#5


9  

Try something like the following in your script:

在你的脚本中尝试如下内容:

set_time_limit(1200);

#6


6  

This is the the right answer:

这是正确答案:

go to

c:\wamp\apps\phpmyadmin3.4.10.1\libraries\config.default.php

find and set

查找和设置

$cfg['ExecTimeLimit'] = 0;

restart all services and done.

重新启动所有服务并完成。

#7


2  

go to the xampp/phpmyadmin/libraries/config.default.php

去xampp / phpmyadmin /图书馆/ config.default.php

and make the following changes

并进行以下更改。

from  $cfg['ExecTimeLimit'] = ’300′;
to  $cfg['ExecTimeLimit'] = ’0′;

#8


1  

PHP's CLI's default execution time is infinite.

PHP的CLI的默认执行时间是无限的。

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.

这将设置一个脚本在被解析器终止之前允许运行的最长时间。这有助于防止编写糟糕的脚本将服务器捆绑在一起。默认设置为30。从命令行运行PHP时,默认设置为0。

http://gr.php.net/manual/en/info.configuration.php#ini.max-execution-time

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.

检查您是否在安全模式下运行PHP,因为它忽略了所有的时间exec设置。

#9


0  

WAMP USERS:

里面的用户:

1) Go to C:\wamp\apps\phpmyadmin

1)转到C:\ wamp \程序\ phpmyadmin

2) Open config.inc

2)打开config.inc

3) Add $cfg['ExecTimeLimit'] = ’3600′; to the file.

3)添加$ cfg[' ExecTimeLimit ']= ' 3600′;到文件。

4) Save the file and restart the server.

4)保存文件并重新启动服务器。

This file overwrites the php.ini and will work for you!

这个文件覆盖了php。我会为你工作的!

#10


0  

In my case, when I faced that error in Phpmyadmin, I tried MySQL-Front and import my DB successfully.

在我的例子中,当我在Phpmyadmin中遇到这个错误时,我尝试了MySQL-Front并成功导入了我的DB。

Note: You can still use the provided solutions under this question to solve your problem in Phpmyadmin.

注意:在这个问题下,您仍然可以使用提供的解决方案来解决Phpmyadmin中的问题。

#11


0  

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.

如果上面的答案不能工作,试着检查你的代码,根据我的经验,有一个无限循环也会导致这个问题。检查你的else if语句。

#12


0  

In Codeignitor version 3.0.x the system/core/Codeigniter.php do not contain the time constraint as well as inserting

在Codeignitor 3.0版。x系统/核心/ Codeigniter。php不包含时间约束和插入。

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

由于codeignitor将使用它自己的函数set_time_limit()来覆盖它,因此将不起作用。因此,要么你必须从codeignitor中删除该函数,或者简单地插入。

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.

在php文件的开头,如果你想把它改成1000秒。将时间设置为0(0),如果您想运行它,只要它需要。

#13


0  

On Xampp, in php.ini you must check mysql.connect_timeout either. So, for example, change it to:

Xampp,在php中。你必须检查mysql。connect_timeout。例如,把它改成:

mysql.connect_timeout = 3600

That time will be always counted in seconds (so 1 hour in my example)

那个时间总是以秒为单位计算(在我的例子中是1小时)

#14


0  

MAMP USERS editing php.ini solves this - there is a line:

MAMP用户编辑php。ini解决了这个问题,有一行:

max_execution_time = 30 ; Maximum execution time of each script, in seconds

max_execution_time = 30;每个脚本的最大执行时间,以秒为单位。

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.

该文件在php/php5.6.25/conf/php中。ini (obviousl需要为您正在使用的php版本润湿文件),您可以从MAMP首选项中找到它。

#15


0  

For Local AppServ

为当地AppServ

Go to C:\AppServ\www\phpMyAdmin\libraries\config.default.php

为其提供AppServ \拥有到C:\ www \ phpMyAdmin \图书馆\ config.default.php

Find $cfg['ExecTimeLimit'] and set value to 0.

找到$cfg['ExecTimeLimit'],并将值设为0。

So it'll look like

所以它会是什么样子

$cfg['ExecTimeLimit'] = 0;

#16


-1  

You can set time limit:

你可以设定时间限制:

ini_set('max_execution_time', 1000000000000000);