Magento / Web Apps

Magento 1.x cron jobs setup

by , , revisited on

We have by far the largest RPM repository with dynamic stable NGINX modules and VMODs for Varnish 4.1 and 6.0 LTS. If you want to install NGINX, Varnish, and lots of useful modules for them, this is your one-stop repository to get all performance-related software.
You have to maintain an active subscription in order to be able to use the repository!

Magento cron jobs

Make sure to setup Magento cron jobs properly:

*/2 * * * * /bin/sh /var/www/html/ cron.php -m=default
*/2 * * * * /bin/sh /var/www/html/ cron.php -m=always

Add the lines above to the crontab of the user that is running your Magento site.
It is important to run Magento cron jobs via script.

This is the most correct and performance efficient way to make sure Magento cron jobs are running:

  • it will call the shell script that will properly execute cron.php file and make sure things are running smoothly
  • since it runs every other minute, it is not heavy on resource usage, however, you may want to run it every minute on powerful servers

Beyond Magento Crons

Larger stores would want to export their products regularly to feed-like files (XML, CSV, and similar formats),
all to promote their products through third-party services.

Because Magento’s internal cron system isn’t perfect, the long-running export tasks may and will hold off the execution of other standard tasks.
This is not desired.

It is recommended to use Aoe_Scheduler plugin and its launcher in favor of the standard

This will not only allow you to enrich your Magento cron system with the ability to track tasks PID, memory usage, etc.
But also you can designate specific tasks to be run in parallel, by using the cron groups feature.

Running Magento cron tasks outside Magento system

For the mentioned long-running job, if you’re not willing to use Aoe_Scheduler’s groups, you can simply set up specific crons to be run as a regular, separate Linux cron task.

For this, you will create a shell/... script which will launch it and disable execution under the Magento cron system.

Citing reference on how to do this:

Remove from the module’s config.xml the cron task in question. Keep a note of the <model>module/observer::methodName</model> line.

Then create a file resembling an example within Magento’s shell/ folder. Something like:

require_once '/path/to/magento/shell/abstract.php';
class Mage_Shell_YourTask extends Mage_Shell_Abstract
    * Run script
    public function run()
        // Call the method here that was previously configured in the module's cron configuration
        $model = Mage::getSingleton('module/observer');
$shell = new Mage_Shell_YourTask();

Now you can simply set up that tasks with desired scheduled in the Linux crontab like so:

30 3 * * * php /path/to/magento/shell/foo.php

This will run these Magento tasks using the Linux cron system, at 3:30 AM every day.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.