PHP或者set_time_limit无影响 [英] PHP set_time_limit no effect

查看:195
本文介绍了PHP或者set_time_limit无影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常痛苦的缓慢的脚本,获取从MySQL大量的数据和出它创建了一个大的报告,它提供给用户在年底为application /强制下载。

I have a very painful slow script that gets lots of data from MySQL and creates a large report out of it that it serves to the user at the end as application/force-download.

长话短说,生产服务器上它不断约30秒后结束(相当一致),并吐出一个空文件来代替。在开发服务器能正常工作,但它确实需要更长的显著执行 - 约90秒。只是为了安全,我在我的php.ini文件设置为的max_execution_time = 2000 ,并运行或者set_time_limit(4000)在我的剧本的开头(数字大大超过预期完成时间,但只是要确定;))。

Long story short, on production server it keeps terminating after about 30 seconds (quite consistently) and spitting out an empty file instead. On development server it works fine, but it does take significantly longer to execute - about 90 seconds. Just to be 'safe', I set my php.ini file to max_execution_time = 2000 and also run set_time_limit(4000) in the beginning of my script (numbers way over the expected completion time, but just to be sure ;)).

这可能是导致我的Web服务器忽略我设置了时间限制,只有30秒后退出对我?

What could be causing my web server to ignore the time limits I set and quit on me after only 30 seconds?

编辑:有一件事我知道肯定是,它需要在code 8-9秒即可完成MySQL的部分,它每一次成功获取过去的那点

one thing I know for sure is that it takes MySQL portion of the code 8-9 seconds to complete, and it successfully gets past that point every time.

推荐答案

也许PHP的safe_mode。

Maybe the PHP safe_mode.

试着做了。

die(ini_get('max_execution_time'))

读取值调用了参数或者set_time_limit后(0); 来看看它实际上得到overwrited

to read the value after you have called the set_time_limit(0); to see if actually it get overwrited.

如果它被overwrited为0,你的脚本还是会死那么原因可能是别的地方在你的code

If it gets overwrited to 0 and your script still dies then the cause could be somewhere else in your code

这篇关于PHP或者set_time_limit无影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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