Reputation: 1009
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!
Upvotes: 1
Views: 1778
Reputation: 1607
In command line there is no $_SERVER['DOCUMENT_ROOT'], so it will search Mage.php in the wrong path. The script can abort because of some php.ini settings which possibly are not applied (i.e. a time limit is set).
Maybe you should access the cron job as a webpage using:
wget http://yourdomain/cron.php
Upvotes: 0
Reputation: 12826
For the cron, just give full folder path to Mage.php and your script will run just fine. When running over apache, the /app
is relative to the webroot folder, but while running as cron it will try to find the folder relative to the filesystem.
Upvotes: 1
Reputation: 115
[26-Sep-2012 12:00:01] PHP Warning: require_once(/app/Mage.php)
That doesn't look like a relative path. Maybe it's looking for Mage.php at the root directory?
Try this: require_once "/full/path/to/app/Mage.php"
Upvotes: 0