Magento EE 1.13 – Omitting Schedule in Module’s Crontab Config XML

configurationcronee-1.13module

I see this in the Mage_Log config.xml

<crontab>
    <jobs>
        <log_clean>
            <run>
                <model>log/cron::logClean</model>
            </run>
        </log_clean>
    </jobs>
</crontab>

and noticed that the <schedule> tag is omitted. I know this cron job is schedule to run at what is set in the System > Configuration > Advanced > System > Log Cleaning configuration, but I don't see how this connection is made. How does Magento know when to run this cron based on the configuration in admin panel? I'm trying to do something similar for a custom module.

I'm using Magento EE 1.13.0.2.

Best Answer

The schedule tag would be omitted here because this cron task is disabled by default. In the admin (System -> Configuration -> System -> Log Cleaning) you'll find the flag to turn it on as well as an option to choose the run/schedule frequency.

When the task is disabled, the schedule config value is stored as NULL so that it never turns up in the cron_schedule table when it's not supposed to run.

As soon as you turn it on, you'll find a value in the core_config_data table for crontab/jobs/log_clean/schedule/cron_expr defining the frequency. This value will be honored just like the one in the xml file would normally be were it present.

Since you're wanting to do something similar here, I would suggest taking a look at the system.xml file from the Mage_Log module to see what scaffolding they have in place to setup the configuration options to store the schedule config value.

Related Topic