Skip to content

Cron Syntax

infinit Support edited this page Jul 12, 2024 · 3 revisions

This is a quick reference to cron syntax and also shows the options supported by infinit.

Allowed fields

 # ┌────────────── second (optional)
 # │ ┌──────────── minute
 # │ │ ┌────────── hour
 # │ │ │ ┌──────── day of month
 # │ │ │ │ ┌────── month
 # │ │ │ │ │ ┌──── day of week
 # │ │ │ │ │ │
 # │ │ │ │ │ │
 # * * * * * *

Allowed values

field value
second 0-59
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names)
day of week 0-7 (or names, 0 or 7 are sunday)

Using multiples values

You may use multiples values separated by comma, the following example runs every minute 1, 2, 4 and 5:

1,2,4,5 * * * *

Using ranges

You may also define a range of values, the following example runs every minute to 1 from 5:

1-5 * * * *

Using step values

Step values can be used in conjunction with ranges, following a range with '/' and a number. e.g: 1-10/2 that is the same as 2,4,6,8,10. Steps are also permitted after an asterisk, so if you want to say “every two minutes”, just use */2. The following example runs a task every two minutes:

*/2 * * * *

Using names

For month and week day you also may use names or short names. The following example runs on Sundays of January and September

* * * January,September Sunday

Or with short names, the following example runs on Sundays of January and September

* * * Jan,Sep Sun