Configuring CRON Expressions in Datastore
The data can be imported into the datastore using a CRON expression as per the schedule configured. The values should be separated by space.
For example, if you enter 0 0 12 * * ?. The meaning of the expression is to run the CRON job at 12:00 PM (noon) every day. Follow the examples link to know how to configure different schedules.
Following are the allowed values and special characters for each schedule type:
Schedule type | Allowed Values | Allowed Special Characters |
---|---|---|
Minutes | 0-59 | , - * / |
Hours | 0-23 | , - * / |
Days of the month | 1-31 | , - * L W C |
Months | 0-11 or JAN - DEC | , - * / |
Days of the week | 1-7 or SAT to SUN | , - * / L C # |
The definition of each special character is as follows:
Special Character | Description |
---|---|
* | This character is used to specify all values. For example, "*" in the minute field means every minute. |
- | This character is used to define a range. For example, "8-11" in the hour field means "the hour 8,9,10, and 11" |
, | This character is used to specify additional values. For example, "MON, WED, FRI" in the day-of-week field means "the days Monday, Wednesday, and Friday" |
/ | This character is used to specify increments. For example, "0/15" in the second's field means "the seconds 0,15,30, and 45". And "5/15" in the second's field means "the seconds 5,20,35, and 50". You can also specify "/" after the "" character; in this case "" is equivalent to having '0' before the '/'. |
L | This character is used to specify "last day of the month" and "last day of the week". For example, the value "L" in the day-of-month field means "the last day of the month" - day 31 for January, day 28 for February or non-leap years. If used in the day-of-week by itself, it simply means "/" or "SAT". But if used in the day-of-week field after another value, it means "the last xxx day of the month" - for example, "6L" means "the last Friday of the month". |
W | This character is used to specify the weekday [MON-FRI] nearest the given day. It is only allowed for the day-of-month. For example, if you were to specify "10W" as the value for the day-of-month field, that means, "the nearest weekday to the 10th of the month". So if the 10th is a Saturday, the trigger will fire on Friday the 9th. If the 10th is a Sunday, the trigger will fire on Monday the 11th. If the 10th is a Tuesday, then it will fire on Tuesday the 10th. However, if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not 'jump' over the boundary of a month's days. The "W" character can only be specified when the day-of-month is a single day, not a range or list of days. |
LW | This character is used to specify "last weekday of the month". |
C | This character is used to calculate against the associated calendar if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of "SC" in the day-of-month field means "the first day included by the calendar on or after the 5th". A value of "1C" in the day-of-week field means "the first day included by the calendar on or after Sunday". |
# | This character is used to specify "the nth" XXX day of the month and is only allowed for the day-of-week field. For example, the value of "6#3" in the day-of-week field means the third Friday of the month (day 6 = Friday and "#3" = the 3rd on in the month). Note that if you specify "#4" and there is no 4 of the given day-of-week in the month, then the trigger will not fire in that month. |
CRON Expression Examples
Below are some examples that can help you configure cron expression:
Example Description | Minutes | Hours | Days of month | Months | Days of week | The cron expression to be configured |
---|---|---|---|---|---|---|
Run at 12:00 PM (noon) every day | 0 | 12 | * | * | * | 0 12 * * * |
Run at 10:15 AM every day | 15 | 10 | * | * | * | 15 10 * * * |
Run every 1 hour starting 01:00 AM | 0 | 1/1 | * | * | * | 0 13/1 * * * |
Run every 5 minutes starting at 2:00 PM and ending at 2:55 PM, every day | 0/5 | 14-15 | * | * | * | 0/5 14-15 * * * |
Run every minute starting at 2:00 PM and ending at 2:05 PM, every day | 0-5 | 14 | * | * | * | 0-5 14 * * * |
Run at 10:15 AM every Monday, Tuesday, Wednesday, Thursday, and Friday | 15 | 10 | * | * | MON-FRI | 15 10 * * MON-FRI |
Run every day at 6 AM | 0 | 6 | * | * | * | 0 6 * * * |
Run every month on the 1st, at noon | 0 | 12 | 1 | * | * | 0 12 1 * * |
Run every Saturday at noon | 0 | 12 | * | * | SAT | 0 12 * * SAT |
Run every hour, only on Saturday | 0 | * | * | * | SAT | 0 * * * SAT |
Run at every 1 hour starting 01:00 AM | 0 | 1/1 | * | * | * | 0 1/1 * * * |
Run at 10:15 AM on the third Friday of every month | 15 | 10 | 15-21 | * | fri | 15 10 15-21 * fri |
Run at 10:15 AM on the last Friday of every month | 15 | 10 | * | * | 5L | 15 10 * * 5L |
Updated over 1 year ago