Why php script may stop?

老子叫甜甜 提交于 2020-01-02 13:25:07

问题


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);

After few hours (between 3-7h) script dies without any visible reason. I've checked

  • 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)

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?


回答1:


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.



来源:https://stackoverflow.com/questions/12194187/why-php-script-may-stop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!