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.
Best Answer
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
):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 pathcrontab/jobs/sitemap_generate/schedule/cron_expr
.This value is read in
Mage_Cron_Model_Observer::_generateJobs
and added to thecron_schedule