Datatypes › Software development

Cron schedule expression

ID cron_expression

DatatypeNot PIIDraft

This record is a draft: it has not been reviewed yet and may be incomplete or wrong. Do not rely on it for compliance decisions. Help improve it (see CONTRIBUTING.md).

Schedule of a cron job: five fields separated by spaces, giving the minute, the hour, the day of the month, the month and the day of the week (0 is Sunday). POSIX allows an asterisk for all values, a number, a range a-b or a comma-separated list in each field; the regexp also accepts the step suffix /n that most cron implementations support. It does not check the value ranges, month and weekday names or @ shortcuts.

Categories
Software development, Date and time
Countries
Global (not tied to a country)
Languages
Common to most languages
Quality
85/100 · missing: mapping (Wikidata, Schema.org, ...), translation
Metacrafter rules
no detection rule yet
Supported by tools
Pydantic and pydantic-extra-types, pyWhat

Regular expression

^(?:\*|[0-9]+(?:-[0-9]+)?(?:,[0-9]+(?:-[0-9]+)?)*)(?:/[0-9]+)?(?:\s+(?:\*|[0-9]+(?:-[0-9]+)?(?:,[0-9]+(?:-[0-9]+)?)*)(?:/[0-9]+)?){4}$

Python re syntax.

Test a value

Examples

ValueDescription
15 3 * * 1-5 Example from the POSIX crontab specification
0 0 1,15 * 1 Example from the POSIX crontab specification
15 3 * * invalid Four fields

Sources

Use this record