Configuring cron expressions
The Segment Query can be executed instantly or it can be scheduled to be executed at a specific date and time.
Follow these steps to schedule a Segment Query:
- Click on the Schedule icon of the respective Segment Query from the Segment list screen. The Schedule configuration screen appears.
- Enter a value in the appropriate field in Cron Expressions format and click Save.
Following are the allowed values and special characters for each field:
Fields | Allowed Values | Allowed Special Characters |
---|---|---|
Seconds | 0-59 | , - * / |
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 specify "no specific value" in the day-of-month and day-of-week fields. This is useful when you need to specify something in one of the two fields but not the other. A field with ? will be ignored. |
- | 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 | Seconds | Minutes | Hours | Days of month | Months | Days of week |
---|---|---|---|---|---|---|
Run at 12:00 PM (noon) every day | 0 | 0 | 12 | * | * | ? |
Run at 10:15 AM every day | 0 | 15 | 10 | * | * | ? |
Run every 1 hour starting 01:00 AM | 0 | 0 | 1/1 | * | * | ? |
Run every 5 minutes starting at 2:00 PM and ending at 2:55 PM, every day | 0 | 0/5 | 14-15 | * | * | ? |
Run every 5 minutes starting at 2:00 PM and ending at 2:55 PM, and run every 5 minutes starting at 6:00 PM and ending at 6:55 PM, every day | 0 | 0/5 | 14-15,18-19 | * | * | ? |
Run every minute starting at 2:00 PM and ending at 2:05 PM, everyday | 0 | 0-5 | 14 | * | * | ? |
Run at 2:10 PM and at 2:44 PM every Wednesday in the month of March | 0 | 10,44 | 14 | ? | 3 | WED |
Run at 10:15 AM every Monday, Tuesday, Wednesday, Thursday and Friday | 0 | 15 | 10 | ? | * | MON-FRI |
Run every day at 6 AM | 0 | 0 | 6 | * | * | ? |
Run every month on the 1st, at noon | 0 | 0 | 12 | 1 | * | ? |
Run every Saturday at noon | 0 | 0 | 12 | ? | * | SAT |
Run every hour, only on Saturday | 0 | 0 | * | ? | * | SAT |
Run at every 1 hour starting 01:00 AM | 0 | 0 | 1/1 | * | * | ? |
Run at 10:15 AM on the third Friday of every month | 0 | 15 | 10 | ? | * | 6#3 |
Run at 10:15 AM on the last Friday of every month | 0 | 15 | 10 | ? | * | 6L |
Updated 4 months ago