dqbr37828 2014-12-10 14:02
浏览 91

php脚本停止执行并显示没有错误

I have a php script that scrapes the web and inserts the scraped data into a database.
This php script runs for a very long time(about a couple of hours).
Sometimes, after the script runs for a long time, the php script just stops executing and shows no error.
The problem isn't caused due to the amount of execution time of the script because i set the php script to an unlimited amount of execution time.

ini_set('max_execution_time', 0);

I also set the php script to show all errors.

ini_set('display_errors',1);
error_reporting(E_ALL);

But I get no error after the php script stops execution.
I also ran the script in several other computers and i still encounter the same problem, so the problem isn't due to server restrictions either.

I researched the issue and apparently it's a networking problem.
The php script stops communicating with the server and disconnects from it(probably because the php script sent a http request and didn't receive any response).

My question is this:

Is there any way I can check for network disconnections through the php script, and resume the script and try to reconnect if there was a network disconnection?

  • 写回答

1条回答 默认 最新

  • doudu9148 2014-12-10 14:06
    关注

    First "set_time_limit" is a better way to use that function and I would check your server's rules and regulations. If it is your private server, then great. If you are renting a VPS or other type of server, it is highly possible that they have restrictions to prevent misuse, like SPAMing and such. Make sure that you are within their rules and go from there.

    评论

报告相同问题?