Skip to main content
MagentoTipsWeb Development

Magento Shell Scripts Timing Out

By 8 January 2015No Comments

So your online business has really taken off and you’ve added a whole load more products. The problem now is that you’ve got so many products that running the Magento Indexes fails due to timeout issues. Luckily Magento provides a solution to this and allows you to run the indexes (as well as the compiler and  log cleaning) from the command line which isn’t subject to Apache’s PHP settings (timeout, max memory etc..). Or so you would think, unfortunately by now you’ve probably discovered that running via the command line also results in a timeout.

For some reason, only known to the Magento devs, the Abstract model that the shell classes are derived from manually parses the .htaccess file from the root of the Magento install and applies any “php_value” or “php_flag” settings to the running process via “ini_set”. So what’s your options:

  1. Edit the .htaccess and increase the timeout settings. This is not a great idea however as it will also allow long running processes to be triggered from the website.
  2. Edit the .htaccess file and remove the php_value and php_flag settings and add them to the VirtualHost (if using Apache) configuration instead. This would result in any request through Apache (i.e. the website) to use the settings but the command line will default back to the PHP defaults.
  3. Create your own shell script which extends the default Magento “indexer.php” (I’ve referred to the file instead of the class name because inexcusably the Magento devs have called the indexer class Mage_Shell_Compiler. Lazy copy and pasting I assume) and override the Mage_Shell_Abstract class’s “_applyPhpVariables” function, which is the function responsible for manually parsing the .htaccess file, so that it does not apply the .htaccess files settings at all.

I hope you found this post early and haven’t spent too much time pulling your hair out looking for a solution to your indexing problems, like I did (well would have if I’d had any hair to pull out).

Close Menu
Portanor House
Manor Court, Manor Royal
Crawley
RH10 9PY

T: +44 (0)330 056 4072
E: [email protected]