CRON Expressions¶
Important
The MongoDB Stitch SDK is deprecated. For guidance on migrating to MongoDB Realm, please see Migrate Your App from Stitch to Realm.
On this page
Overview¶
CRON expressions are user-defined strings that use standard cron job syntax to define when a scheduled trigger should execute. Whenever all of the fields in a CRON expression match the current date and time, Stitch fires the trigger associated with the expression.
Expression Syntax¶
Format¶
CRON expressions are strings composed of five space-delimited fields. Each field defines a granular portion of the schedule on which its associated trigger executes:
* * * * *
│ │ │ │ └── weekday...........[0 (SUN) - 6 (SAT)]
│ │ │ └──── month.............[1 (JAN) - 12 (DEC)]
│ │ └────── dayOfMonth........[1 - 31]
│ └──────── hour..............[0 - 23]
└────────── minute............[0 - 59]
Field | Valid Values | Description |
---|---|---|
minute |
[0 - 59] | Represents one or more minutes within an hour. Example If the |
hour |
[0 - 23] | Represents one or more hours within a day on a 24-hour clock. Example If the |
dayOfMonth |
[1 - 31] | Represents one or more days within a month. Example If the |
month |
1 (JAN) 7 (JUL) 2 (FEB) 8 (AUG) 3 (MAR) 9 (SEP) 4 (APR) 10 (OCT) 5 (MAY) 11 (NOV) 6 (JUN) 12 (DEC) |
Represents one or more months within a year. A month can be represented by either a number (e.g. Example If the |
weekday |
0 (SUN) 1 (MON) 2 (TUE) 3 (WED) 4 (THU) 5 (FRI) 6 (SAT) |
Represents one or more days within a week. A weekday can be represented by either a number (e.g. Example If the |
Field Values¶
Each field in a CRON expression can contain either a specific value or an expression that evaluates to a set of values. The following table describes valid field values and expressions:
Expression Type | Description |
---|---|
All Values
(
* ) |
Matches all possible field values. Available in all expression fields. Example The following CRON expression schedules a trigger to execute once every minute of every day: |
Specific Value
(
<Value> ) |
Matches a specific field value. For fields other than Available in all expression fields. Example The following CRON expression schedules a trigger to execute once every day at 11:00 AM UTC: |
List of Values
(
<Expression1>,<Expression2>,... ) |
Matches a list of two or more field expressions or specific values. Available in all expression fields. Example The following CRON expression schedules a trigger to execute once every day in January, March, and July at 11:00 AM UTC: |
Range of Values
(
<Start Value>-<End Value> ) |
Matches a continuous range of field values between and including two specific field values. Available in all expression fields. Example The following CRON expression schedules a trigger to execute once every day from January 1st through the end of April at 11:00 AM UTC: |
Modular Time Step
(
<Field Expression>/<Step Value> ) |
Matches any time where the step value evenly divides the
field value with no remainder (i.e. when Available in the Example The following CRON expression schedules a trigger to execute on the 0th, 25th, and 50th minutes of every hour: |