Cron Atlas

Azure Functions NCRONTAB expressions

Six fields with seconds first, read by the NCrontab library. It looks like cron with one extra field, but it combines the day fields the other way round.

second0
minute30
hour9
day of monthevery day
monthJanuary
day of weekMon

At 09:30, on Mondays, in January.

Next 10 runs

Clock changes

In the other dialects

“Same schedule” means the same clock times. Schedulers still treat a clock change differently, as the table on the home page shows.

Keyboard: / edit the expression, 1 to 6 change dialect, t time zone, n next clock change, c copy the link, Esc leave a field.

Fields

FieldValuesSpecial characters
Second0–59 (omit for the 5-field form)* , - /
Minute0–59* , - /
Hour0–23* , - /
Day1–31* , - /
Month1–12 or names* , - /
Day of week0–6, where 0 is Sunday, or names* , - /

Special characters

*
All values: 0 * 5 * * * runs every minute of hour 5.
-
A range: 5-7 * * * * *. NCrontab swaps a backwards range, so 10-5 means 5 through 10, not a wrap-around.
,
A set: 5,8,10 * * * * *.
/
An interval: 0 */5 * * * *.
Names
English and case-insensitive: Mon, Monday, Jan. NCrontab takes the first prefix match, so J is January and Ju is June. Use three letters.

The two day fields

NCrontab checks both day fields. 0 0 12 1 * Mon fires only when the 1st is a Monday, where Unix cron would fire on every 1st and every Monday. The docs do not call this out, but NCrontab’s code and its test suite do it. Useful side effect: 0 0 9 1-7 * Mon really is the first Monday of the month.

Time zones

UTC by default. Set the WEBSITE_TIME_ZONE app setting: a Windows name on Windows, a tz database name on Linux Premium or Dedicated. It is not supported on Linux Consumption or Flex Consumption, where Microsoft warns that setting it can cause SSL issues and stop metrics.

Clock changes

Microsoft says only that WEBSITE_TIME_ZONE adjusts for time changes. The details are in the CronSchedule source, which this tool ports and checks against its tests. A time in the gap moves forward by the size of the gap, so 02:30 becomes 03:30. In the repeated hour, a fixed-time schedule runs once. A schedule with *, / or - in its time fields runs through both passes.

Gotchas

  • A 5-field expression gets second 0. The docs’ note says both forms are supported.
  • A value of 5 in the hour field means 05:00, not every 5 hours.
  • If an expression is invalid, the portal’s function test shows a 404. With Application Insights connected, more detail is logged there.
  • Timer triggers do not retry after a failure. The function next runs at its next scheduled time.
  • runOnStartup also fires on every scale-out and restart. Microsoft says not to set it in production.
  • A TimeSpan such as 01:00:00 only works on an App Service plan. If the first number is 24 or more, the format is days:hours:minutes, so 24:00:00 is 24 days.
  • If a function app scales out, one instance runs the timer. Function apps sharing storage can collide if they share a host ID.

Examples to try

Sources

Other dialects