0

There are lots of tutorials/manuals/forums for setting up a cron in Magento. I even asked a question (here) before, which philwinkle answered perfectly.

However there is one thing that I still could not get to know. Can anyone throw some light?

I've set up the order export cron as bellow in etc/config.xml of my module.

Step -1

<crontab>
        <jobs>
            <order_export_observer>
                <schedule><cron_expr>0 0 * * *</cron_expr></schedule>
                <run><model>orderExport/observer::check</model></run>
            </order_export_observer>
            ...
        </jobs>
        ...   
</crontab>

With the above settings, this would export a CSV file in the proper format once a night (at midnight) I think.

Step-2

I've created a cron in the Nexcess

1/55 * * * *  /usr/bin/php -f /home/html/www.example.com/html/cron.php

This will run after every 55 mins.

Now the actual Problem:

I had to supply cron expression for both in config.xml and in Nexcess Control Panel with 0 0 * * * and 1/55 * * * * respectively. Which expression Magento will take into account? Only one or both? And how the order export will be scheduled? I hope I have been able to describe the problem.

2

The way that Magento CRON works is that it will process jobs based on the schedule you've defined in the config.xml CRON.

The way those jobs are aggregated into the cron_schedule table is, when the system CRON runs (the one you identified as being set up in Nexcess) it tells Magento to insert records into the queue to be worked. After it has aggregated all jobs it reviews the queue to see if any jobs are within the window of the last time it has run and the current time to execute scheduled tasks. It does all of this when it runs via the cron.php script.

The problem is that you have set up that script to only run every 55 minutes.

Typically the system cron is configured to execute every 5 minutes, or even every minute. All this does is tell Magento to review jobs ready to be run. If it is configured in this manner then it should run as you expect.

If all else fails, contact Nexcess support. Those guys'll get you squared away.

More reading:

http://magestudyguide.com/includes/answers/13.html

Install this module by @fbrnc to get more control over your cron and have a visualization of when they run:

https://github.com/fbrnc/Aoe_Scheduler

  • 1
    So, I should set up cron to run for every 5 mins in Nexcess, which will review cron jobs inserted from various <crontab.. from config.xml every 5 mins. to check if any job is scheduled to run. By this way cron expressions in config.xml is important. Am I right? – Magento Learner Mar 11 '14 at 6:34
  • 1
    That is correct. – philwinkle Mar 11 '14 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.