Configuring cron expressions

The Segment Query can be executed instantly or it can be scheduled to be executed at a specific date and time.

1919

Follow these steps to schedule a Segment Query:

  1. Click on the Schedule icon of the respective Segment Query from the Segment list screen. The Schedule configuration screen appears.

  1. 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:

FieldsAllowed ValuesAllowed Special Characters
Seconds0-59, - * /
Minutes0-59, - * /
Hours0-23, - * /
Days of the month1-31, - * ? L W C
Months0-11 or JAN - DEC, - * /
Days of the week1-7 or SAT to SUN, - * ? / L C #

The definition of each special character is as follows:

Special CharacterDescription
*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 '/'.
LThis 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".
WThis 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.
LWThis character is used to specify "last weekday of the month".
CThis 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 DescriptionSecondsMinutesHoursDays of monthMonthsDays of week
Run at 12:00 PM (noon) every day0012**?
Run at 10:15 AM every day01510**?
Run every 1 hour starting 01:00 AM001/1**?
Run every 5 minutes starting at 2:00 PM and ending at 2:55 PM, every day00/514-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 day00/514-15,18-19**?
Run every minute starting at 2:00 PM and ending at 2:05 PM, everyday00-514**?
Run at 2:10 PM and at 2:44 PM every Wednesday in the month of March010,4414?3WED
Run at 10:15 AM every Monday, Tuesday, Wednesday, Thursday and Friday01510?*MON-FRI
Run every day at 6 AM006**?
Run every month on the 1st, at noon00121*?
Run every Saturday at noon0012?*SAT
Run every hour, only on Saturday00*?*SAT
Run at every 1 hour starting 01:00 AM001/1**?
Run at 10:15 AM on the third Friday of every month01510?*6#3
Run at 10:15 AM on the last Friday of every month01510?*6L