问题描述
我跑在PHP真正的长期任务。这是一个网站履带式和它要有礼貌和睡眠,持续5秒每页为prevent服务器过载。脚本开头:
I'm running really long task in php. It's a website crawler and It has to be polite and sleep for 5 seconds each page to prevent server overloading. Script starts with:
ignore_user_abort(1);
session_write_close();
ob_end_clean();
while (@ob_end_flush());
set_time_limit(0);
ini_set('max_execution_time',0);
几个小时后(3-7h之间)脚本死亡,没有任何明显的原因。
我检查
After few hours (between 3-7h) script dies without any visible reason.I've checked
- Apache的错误日志(无)
- php_errors.log(无)
- 错误输出(调试输出的10 578 467b,没有错误)
- 内存消耗(稳定,3M左右从
memory_get_usage(真)
检查每5秒,限制设置为512M)
- apache error log (nothing)
- php_errors.log (nothing)
- output for errors (10 578 467b of debug output, no errors)
- memory consumption (stable, around 3M from
memory_get_usage(true)
checked every 5 sec, limit set to 512M)
这不是浏览器,因为我是用wget和Chrome浏览器检查与类似的原因。
输出将被送到每2-3秒的浏览器,所以我不认为这是错+ I忽略用户中止。
It's not browser, cause I was using wget and chrome to check with the similar reason.Output is sent to browser every 2-3 seconds, so I don't think that's the fault + I ignore user abort.
是否有任何其他地方我可以检查发现的问题?
Is there any other place I can check to find the issue?
推荐答案
我觉得有一个在你的脚本,而不是Apache。
I think there's a problem in the rest of your script, not Apache.
尝试分析使用与应用程序光探查如并记录,可能是
Try profiling your application using the register_tick_function with a light profiler like this and logging the memory usage, may be that.
这篇关于为什么PHP脚本可能会停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!