3

当我在 make 中运行导入 cronjob 时,我遇到了这个奇怪的问题。它处理一个 1.5GB 的 XML 文件,其中包含大约 400.000 个产品。该脚本运行良好,需要几个小时才能完成,但大约 500/600 秒后,我收到了来自 cron-deamon 的以下电子邮件。

PHP 警告:file_get_contents(http://test.nl/admin/cron_index.php?route=module/EZImport&cron):打开流失败:HTTP 请求失败!第 8 行 /home/test.nl/public_html/admin/controller/tool/EZImport_cron.php 中的 HTTP/1.1 500 内部服务器错误

警告:file_get_contents(http://test.nl/admin/cron_index.php?route=module/EZImport&cron):打开流失败:HTTP 请求失败!第 8 行 /home/test.nl/public_html/admin/controller/tool/EZImport_cron.php 中的 HTTP/1.1 500 内部服务器错误 bool(false)

我的 apache 错误日志说:

[Fri Nov 02 09:43:39 2012] [warn] [client 176.9..174] (104) Connection reset by peer: mod_fcgid: 从 FastCGI 服务器读取数据时出错 [Fri Nov 02 09:43:39 2012] [error ] [client 176.9..174] 脚本头过早结束:cron_index.php

这是 cronjob 调用的 cron 文件

    require_once('../../config.php');
    $opts = 数组('http' =>
        数组('超时' => 36000)
    );
    $context = stream_context_create($opts);
    $url = HTTP_SERVER."cron_index.php?route=module/cronMod&cron";
    $result = file_get_contents($url, false, $context);
    var_dump($result);
    死();

我需要通过 file_get_contents 运行这个 cron

环境:

Debian, OpenCart

webmin (php config) 中的最大执行时间设置为 36000 秒。

4

2 回答 2

1

处理一个 1.5GB 的 XML 文件

呃,这有点傻——你至少需要通过 2 次才能验证文档格式是否正确,并且有很多坏事发生的空间。

webmin (php config) 中的最大执行时间设置为 36000 秒

到底是为了什么?

您还需要为 Web 服务器和客户端和服务器之间的链中的所有其他组件配置超时,但是尝试通过 HTTP 传输 1.5Gb 文件只是愚蠢的——你可能会让它工作——但这​​不是正确的方法解决这个问题。将其分解为更易于管理的块。

于 2012-11-02T09:28:51.547 回答
0

尝试set_time_limit(0)在脚本中使用或更改 php.ini 中的时间限制

于 2012-11-02T09:19:13.423 回答