Cron Expressions
Cron expressions are used to define the schedule of a plan (the frequency of the plan execution). Besides the Cron expression you can also define a delay in the plan execution. The delay is used to create more complex schedules. It can be set to a number (positive or negative) of minutes, hours, days, or weeks.
Plans cannot be executed more often than every three hours.
Format
Cron expressions are strings that consist of five fields separated by white space.
Field name | Allowed values | Allowed special characters |
---|---|---|
Minutes | 0-59 |
|
Hours | 0-23 |
|
Day of month | 1-31 |
|
Month | 1-12 or JAN-DEC |
|
Day of week | 0-6 or MON-SUN |
|
Special characters
Asterisk ( * )
Asterisks indicate that the cron expression matches all field values. E.g., using an asterisk in the 5th field (day of week) indicates every day.
Slash ( / )
Slashes describe increments of ranges.
For example, 0-12/2
in the hour field is the same as 0,2,4,6,8,10,12 (every 2 hours from 00:00 AM to 12:00 PM, inclusive).
Comma ( , )
Commas are used to separate items of a list. For example, using JAN,MAY,NOV
in the 4th field (month) means January, May,
and November.
Hyphen ( - )
Hyphens define ranges. For example, 14-17
in the 2nd field (hours) indicates every hour between 14:00 PM and 17:00 PM,
inclusive.
L
L means the last day of the month or the last day of the week (MON-SAT) in the month.
When used in the day of week field combined with a number, 1L
, it simply means "the last Monday" of a given month.
However, when used in the day of month field alone, it indicates the month's final day.
W
W means weekday (Monday-Friday) nearest to the given day. When used in the day of month field by itself (e.g., 5W
),
it specifies a weekday (Monday-Friday) nearest to the 5th of the month.
When combined with L, it means "the last business day of the month."
Hash ( # )
Hashes are used in the day of week field to specify the nth day of the month.
For example, 6#3
means the third Saturday of the month (day 6 = Saturday and "#3" = the 3rd (day) of the month).
Examples
Below you can find some examples of Cron expressions. You can use them as a reference when creating your own.
Verbal Description | CRON Expression |
---|---|
At 11:00 PM, between days 11 and 17 of the month, and on Friday |
|
At 06:00 PM, only in October |
|
At 12:00 AM, only on Saturday every six months |
|
At 12:00 AM every six months |
|
At 01:00 AM, on the fourth Saturday of the month |
|
At 11:00 AM, on the second Tuesday of the month, only in February, May, August, and November |
|
Three days after Patch Tuesday (you can do it using Delay) | Cron: |
At 12:00 AM, on the first Saturday of every month |
|
At 12:00 AM, on the third Friday of every three months |
|