我的PHP脚本恰好在120秒后停止 [英] my php script stops exactly after 120 seconds

查看:170
本文介绍了我的PHP脚本恰好在120秒后停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在逐行将表数据导入到mysql表(其中表中的行数超过25000)时正在使用codeigniter,因此从一个表读取并插入另一个表需要花费时间.

I am using codeigniter while i am importing table data row by row to a mysql tables where rows are more than 25000 in the table so it takes time to read from one table and insert into another table.

我注意到,每次我运行脚本时,就像: http://domain.local/importdata 它会在导入一些行并检查完执行时间后立​​即停止脚本,而该时间总是恰好为120秒.

I noticed that every time i run the the my script like: http://domain.local/importdata it stops the script after importing some rows and after checking the time of its execution its exactly 120 seconds always.

我尝试设置set_time_limit(0);但仍然无法使用,它会在120秒后停止.

I tried to set_time_limit(0); but no use still it stops after 120 seconds.

在phpinfo()中,它显示默认的max_execution_time为300.

in phpinfo() it shows that default max_execution_time is 300.

此外,我在Windows计算机上使用zend服务器.

In addition I am using zend server on windows machine.

提前谢谢.

推荐答案

首先,您应该使用的函数是 set_time_limit ().

First, the function you should be using is set_time_limit().

假设这只是一个错字,则您的服务器管理员可能已对该服务器设置了限制.这意味着您不能超过该限制.试想一下,如果某个地方有无限循环,您的代码将永远不会超时.要进行验证,请尝试使用set_time_limit(0)并执行phpinfo().您将在输出中看到两个值.在最右边的列中是PHP配置中的主值,另一个是优先于本地值的本地值.

Assuming that it's just a typo, your server administrator may have placed restriction on the server. This means you cannot go over that limit. Just imagine if you have an endless loop somewhere and your code will never timeout. To verify, try using set_time_limit(0) and execute phpinfo(). You will see in the output two values. In the right-most column the master value which is in the PHP configuration, and the other one the local value which will take precedence.

Zend手册提到您不应将其用于执行时间较长的文件.请按照有关如何将文件列入黑名单的说明进行操作.另外,如果您使用的是Apache,请在etc目录中的zendenabler.conf中检查RequestTimeout和ConnectionTimeout.我认为它停止的原因不是因为PHP,而是因为Apache或Zend.

The Zend manual mentions that you should not be using it for files with long execution times. Follow the instructions on how you can blacklist a file. Also, check RequestTimeout and ConnectionTimeout in zendenabler.conf in the etc dir if you are using Apache. I think the reason why it's stopping is not because of PHP but because of Apache or Zend.

这篇关于我的PHP脚本恰好在120秒后停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆