Copyright © 2019-2023 Michael Truog
Version: 2.0.6 Jun 20 2023 19:11:23 ------------------------------------------------------------------------
Authors: Michael Truog (mjtruog at protonmail dot com).
Field name Required Allowed values Allowed special characters ---------- -------- -------------- -------------------------- Seconds No 0-59 * / , - ~ Minutes Yes 0-59 * / , - ~ Hours Yes 0-23 * / , - ~ Day of month Yes 1-31 * / , - ~ L W Month Yes 1-12 or JAN-DEC * / , - ~ Day of week Yes 0-6 or SUN-SAT * / , - ~ L # Year No 1970–9999 * / , - ~
An asterisk indicates that the cron expression matches for all values of the field.
Slashes can be combined with ranges to specify step values. For example, */5 in the minutes field indicates every 5 minutes.
Commas are used to separate items of a list. For example, using "MON,WED,FRI" in the day-of-week field means Mondays, Wednesdays and Fridays.
Hyphens define ranges. For example, 2000–2010 indicates every year between 2000 and 2010 inclusive.
Tildes define random ranges. For example, 0~59 will result in a random value between 0 and 59 inclusive.
A random range can be used with a step value. For example, 0~59/10 will use a random offset for the first sequence value between 0 and 9 inclusive. The field's min/max values may be used by excluding the random range values as ~ or ~/10.
Random values are determined when the expression is parsed with the random value remaining constant afterwards. The purpose of the randomness is to avoid any thundering herd problems between separate uses of similar cron expressions (https://en.wikipedia.org/wiki/Thundering_herd_problem).
'L' stands for "last". When used in the day-of-week field, it allows you to specify constructs such as "the last Friday" ("5L") of a given month. In the day-of-month field, it specifies the last day of the month.
The 'W' character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify "15W" as the value for the day-of-month field, the meaning is: "the nearest weekday to the 15th of the month". So, if the 15th is a Saturday, the trigger fires on Friday the 14th. If the 15th is a Sunday, the trigger fires on Monday the 16th. If the 15th is a Tuesday, then it fires on Tuesday the 15th. However, if you specify "1W" as the value for day-of-month, and the 1st is a Saturday, the trigger fires on Monday the 3rd, as it does not 'jump' over the boundary of a month's days.
This implementation allows the W character to be used in a list. For example, "1W,15W" is valid in the day-of-month field.
The W character can be combined with L as LW to mean "the last business day of the month".
'#' is allowed for the day-of-week field, and must be followed by a number between one and five. It allows you to specify constructs such as "the second Friday" of a given month. For example, entering "5#3" in the day-of-week field corresponds to the third Friday of every month.
* If only six fields are present, a 0 second field is prepended * If only five fields are present, a 0 second field is prepended and a wildcard year field is appended * The range for the day-of-week field is 0-7 instead of 0-6, with 7 as Sunday (like 0) (BSD and ATT disagreed about this in the past) * The month names are case-insensitive * The day-of-week names are case-insensitive * Random range support (with ~) is based on OpenBSD cron
expression() = {field_seconds(), field_minutes(), field_hours(), field_day_of_month(), field_month(), field_day_of_week(), field_year()}
expression_strings() = {nonempty_string(), nonempty_string(), nonempty_string(), nonempty_string(), nonempty_string(), nonempty_string(), nonempty_string()}
field_day_of_month() = [1..31 | last_day_of_month | {weekday, last_day_of_month | 1..31}, ...] | undefined
field_day_of_week() = [0..6 | {last_day_of_week, 0..6} | {every, 1..5, 0..6}, ...] | undefined
field_hours() = [0..23, ...] | undefined
field_minutes() = [0..59, ...] | undefined
field_month() = [1..12, ...] | undefined
field_seconds() = [0..59, ...] | undefined
field_year() = [1970..9999, ...] | undefined
state() = #cloudi_cron{expression_strings = expression_strings(), expression = expression()}
expression/1 |
Provide the cron expression string.. |
new/1 |
Create a parsed representation of a cron expression.. |
next_datetime/2 |
Determine the next datetime based on the cron expression.. |
expression(Cloudi_cron::state()) -> nonempty_string()
new(Input::nonempty_string()) -> state()
next_datetime(DateTime::calendar:datetime(), Cloudi_cron::state()) -> calendar:datetime() | undefined
Generated by EDoc