In the blog “kbmMW Scheduler Tidbits #2 – CRON’ I explained how to use the nice Unix like Cron feature in kbmMW’s scheduler.
The original syntax already supported Cron extended features like year, but in kbmMW we don’t stop there. We have extended it further to also support seconds for easy of use.
The following explains how the various Cron parts are to be specified.
If only 5 parts are given, kbmMW will assume that a standard Cron format is used. Hence the 5 parts are:
minute hour day month dayofweek
If 6 parts are given, kbmMW will default assume that it’s the year extended Cron format that is used. Hence the 6 parts are:
minute hour day month dayofweek (year)
(‘year’ part is optional)
kbmMW however now supports specifying a Cron TkbmMWScheduleCronMode argument as part of the Cron method to make it interpret the parts differently. For example to ask kbmMW to interpret a 5 or 6 part Cron as:
(second) minute hour day month dayofweek
(‘second’ part is optional), you would provide the mode value mwscmExtendedSecond.
And to be able to provide a 7 part Cron argument, where both extended seconds and extended year is provided like this:
second minute hour day month dayofweek year
(no parts are optional), you would provide the mode value mwscmExtendedSecondAndYear.
Examples:
// At the 8 and 9 minutes past the hour (standard 5 part). Scheduler.Schedule(OnTestEvent).Cron('8,9 * * * *').NamedAs('cron1a').Activate; Scheduler.Schedule(OnTestEvent).Cron('8,9 * * * *').NamedAs('cron1b',mwscmExtendedSecond).Activate; // Every 30 seconds Scheduler.Schedule(OnTestEvent).Cron('/30 * * * * *').NamedAs('cron2',mwscmExtendedSecond).Activate; // Exactly at 8:30:35 and 8:30:45 March 4 the years 2025 and 2026 Scheduler.Schedule(OnTestEvent).Cron('35,45 30 8 4 3 * 2025,2026',mwscmExtendedSecondAndYear).NamedAs('cron3').Activate;
kbmMW Scheduler Tidbits #1 – Async methods
kbmMW Scheduler Tidbits #2 – CRON