7

The timing for a number of Magento's core cron tasks such as sitemap, stock alert notifications and log cleaning can be adjusted via the admin's System Config. This means they are not defined inside the cronjob node of a module's config.xml however they do get written into the cron_schedule table like other jobs.

How does the cron scheduler find those jobs? My guess is that there is an event thrown during the schedule generation, but I can't see any instances of dispatchEvent within Mage_Cron.

13

These kind of cronjobs have a backend model that is called when the cron settings are called. This model inserts the cron job run time in core_config_data and the cron schedule reads it from there.
Let's take as example the sitemap cron. The field 'frequency' has this backend model (see app/code/code/Mage/Sitemap/etc/system.xml):

<backend_model>adminhtml/system_config_backend_sitemap_cron</backend_model> 

When the frequency is saved (and the rest of the fields with it) this method is called: Mage_Adminhtml_Model_System_Config_Backend_Sitemap_Cron::_afterSave().
This inserts in the table core_config_data the cron expression with this path crontab/jobs/sitemap_generate/schedule/cron_expr.
This value is read in Mage_Cron_Model_Observer::_generateJobs and added to the cron_schedule

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.