PHP 脚本停止任意运行,没有错误 [英] PHP script stops running arbitrarily with no errors

查看:66
本文介绍了PHP 脚本停止任意运行,没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 PHP 脚本,它似乎在大约 20 分钟后停止运行.

I have a PHP script that seemed to stop running after about 20 minutes.

为了找出原因,我编写了一个非常简单的脚本来看看它可以运行多长时间,而没有任何复杂的代码让我感到困惑.

To try to figure out why, I made a very simple script to see how long it would run without any complex code to confuse me.

我发现这个简单的无限循环也发生了同样的事情.在运行 15 到 25 分钟之间的某个时间点,它停止而没有任何消息或错误.浏览器显示完成".

I found that the same thing was happening with this simple infinite loop. At some point between 15 and 25 minutes of running, it stops without any message or error. The browser says "Done".

我已经解决了我能想到的所有可能的事情:

I've been over every single possible thing I could think of:

set_time_limit ( session.gc_maxlifetime in the php.ini)
memory_limit
max_execution_time

脚本停止的点不一致.有时会停在 15 分钟,有时会停在 22 分钟.

The point that the script is stopped is not consistent. Sometimes it will stop at 15 minutes, sometimes 22 minutes.

请,任何帮助将不胜感激.

Please, any help would be greatly appreciated.

它托管在 1and1 服务器上.我联系了他们,但他们不为开发人员造成的错误提供支持.

It is hosted on a 1and1 server. I contacted them and they don't provide support for bugs caused by developers.

推荐答案

感谢大家的评论.尤其是 James Hartig 的,你非常有帮助,让我走上了正确的道路.我仍然不知道是什么问题.我使用 SSH 在服务器上运行它,只需使用 exec() 命令和 ignore_user_abort().但它仍然会超时.所以,我只需要把它分成小块,每个小块只运行大约 2 分钟,并使用会话变量/数组来存储我离开的地方.我很高兴现在完成了这个相当简单的项目,并且对 1and1 非常生气.哦,好吧...

I appreciate everyone's comments. Especially James Hartig's, you were very helpful and sent me on the right path. I still don't know what the problem was. I got it to run on the server with using SSH, just by using the exec() command as well as the ignore_user_abort(). But it would still time out. So, I just had to break it into small pieces that will run for only about 2 minutes each, and use session variables/arrays to store where I left off. I'm glad to be done with this fairly simple project now, and am supremely pissed at 1and1. Oh well...

这篇关于PHP 脚本停止任意运行,没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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