我有一个简单的学习网站,可以解析其他网站的源代码。问题是有时通过file_get_contents()读取源时会出错。这很好,但不知何故,php脚本在发生此错误后重新开始。因此,出现的错误越多,创建和执行的并发“线程”就越多。
php脚本在这里:http://pastebin.com/vKZe6cCC
leaderboeard_parser包括:http://pastebin.com/WMd5aWGB
这是预期的输出:
30.10.2014 12:55:17 Uploading test statistics ...
30.10.2014 12:55:17: - hardcore season uploaded. Errors: 1
30.10.2014 12:55:17: - hardcore non-season uploaded. Errors: 1
30.10.2014 12:55:17: - softcore season uploaded. Errors: 2
30.10.2014 12:55:17: - softcore non-season uploaded. Errors: 0
Uploading of US statistics done.
这是通常的意外输出:
30.10.2014 12:55:17 Uploading test statistics ...
30.10.2014 12:55:17: - hardcore season uploaded. Errors: 1
30.10.2014 12:55:48 Uploading test statistics ...
30.10.2014 12:55:17: - hardcore non-season uploaded. Errors: 1
30.10.2014 12:55:48: - hardcore season uploaded. Errors: 0
30.10.2014 12:55:17: - softcore season uploaded. Errors: 2
30.10.2014 12:56:18 Uploading test statistics ...
30.10.2014 12:55:48: - hardcore non-season uploaded. Errors: 1
30.10.2014 12:55:17: - softcore non-season uploaded. Errors: 0
Uploading of test statistics done.
30.10.2014 12:55:48: - softcore season uploaded. Errors: 1
30.10.2014 12:56:18: - hardcore season uploaded. Errors: 2
30.10.2014 12:56:48 Uploading test statistics ...
30.10.2014 12:55:48: - softcore non-season uploaded. Errors: 0
Uploading of test statistics done.
30.10.2014 12:56:18: - hardcore non-season uploaded. Errors: 0
30.10.2014 12:56:48: - hardcore season uploaded. Errors: 0
30.10.2014 12:56:18: - softcore season uploaded. Errors: 0
30.10.2014 12:56:48: - hardcore non-season uploaded. Errors: 0
30.10.2014 12:56:18: - softcore non-season uploaded. Errors: 0
Uploading of test statistics done.
30.10.2014 12:57:19 Uploading test statistics ...
30.10.2014 12:56:48: - softcore season uploaded. Errors: 0
30.10.2014 12:57:19: - hardcore season uploaded. Errors: 0
30.10.2014 12:56:48: - softcore non-season uploaded. Errors: 1
Uploading of test statistics done.
30.10.2014 12:57:19: - hardcore non-season uploaded. Errors: 0
30.10.2014 12:57:50 Uploading test statistics ...
30.10.2014 12:57:19: - softcore season uploaded. Errors: 0
30.10.2014 12:57:50: - hardcore season uploaded. Errors: 1
30.10.2014 12:57:19: - softcore non-season uploaded. Errors: 1
Uploading of test statistics done.
30.10.2014 12:57:50: - hardcore non-season uploaded. Errors: 0
30.10.2014 12:57:50: - softcore season uploaded. Errors: 1
30.10.2014 12:57:50: - softcore non-season uploaded. Errors: 0
Uploading of test statistics done.
另一个输出(脚本运行了39分钟,怎么样?):pastebin.com/AnNJMvfL
正如您所看到的,似乎脚本的多个实例同时运行,我不知道为什么会发生这种情况。这也在免费托管服务器上运行。
在论坛上也发现ftp客户端有时会错误地覆盖文件,所以我创建了新文件(源代码,日志),但没有改变。
如果有人可以帮助我或者至少提出一些可能出错的话,那就太棒了。
再次感谢你。
编辑:我在不同的服务器上尝试过它,它的工作原理如何。那可能是什么?什么样的设置会导致这种重复?