1

I created a product import script for Magento around a year ago and it's been running successfully since then, downloading several XML files containing the product catalogue, stock quantities and discontinued product list, as well as the images files associated with each product.

Suddenly this week the script no longer runs to completion. It appears to just end abruptly but with no error message being shown either on screen or on the server's error.log file in the directory containing the script.

I have the following at the head of my script so I ought to be seeing errors if they are actually occurring:

error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('display_errors', 'On');

The only thing I've seen that might be related, but I'm not convinced because I don't see it at all when I run the script from my browser - it only occurs if the script is run from crontab (php .../public_html/import/ss365products.php >/dev/null 2>&1), is the following in the error.log file:

[26-Sep-2012 12:00:01] PHP Warning:  require_once(/app/Mage.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in .../public_html/import/TempProducts.php on line 5

I'm not really sure why I'm getting that at all being that Mage.php hasn't gone anywhere!

So... I'm really not sure where to look now to debug this issue. Any advice greatly recieved!

4

4 回答 4

1

对于 cron,只需提供 Mage.php 的完整文件夹路径,您的脚本就会运行良好。在 apache 上运行时,它/app是相对于 webroot 文件夹的,但在作为 cron 运行时,它会尝试查找相对于文件系统的文件夹。

于 2012-09-26T20:02:19.793 回答
0
[26-Sep-2012 12:00:01] PHP Warning:  require_once(/app/Mage.php)

这看起来不像是相对路径。也许它正在根目录中寻找 Mage.php ?

试试这个:require_once "/full/path/to/app/Mage.php"

于 2012-09-26T19:21:14.643 回答
0

利用require_once(__DIR__ . '/app/Mage.php');

于 2012-09-26T19:21:43.723 回答
0

在命令行中没有 $_SERVER['DOCUMENT_ROOT'],所以它会在错误的路径中搜索 Mage.php。由于某些可能未应用的 php.ini 设置(即设置了时间限制),该脚本可能会中止。

也许您应该使用以下命令将 cron 作业作为网页访问:

wget http://yourdomain/cron.php

于 2012-10-05T09:17:16.370 回答