cron is a time-based task management system for Unix-like operating systems. Users can use cron to run periodic tasks (which can be commands and scripts) at fixed times, dates, and intervals. cron is commonly used in operations and administration, but it can also be used elsewhere, such as downloading files and emails periodically. The word cron comes from the Greek chronos (χρόνος), meaning time.
cron expression structure
General form
| 1st | 2nd | 3rd | 4th | 5th | 6th | |
|---|---|---|---|---|---|---|
| Field | Minute | Hour | Day | Month | Week | Year |
| Range | 0-59 | 0-23 | 1-31 | 1-12 | 0-6 (Sunday is 0) (fill in ? if unsure) | 1970-2099 |
Months can also be written as JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC. Days of the week can also be written as SUN, MON, TUE, WED, THU, FRI, SAT. Note: ranges must be integer values.
Special form
Used in some places. Compared to the general form, there are no seconds or years; everything else is the same
| 1st | 2nd | 3rd | 4th | 5th | |
|---|---|---|---|---|---|
| Field | Minute | Hour | Day | Month | Week |
| Range | 0-59 | 0-23 | 1-31 | 1-12 | 0-6 (Sunday is 0) (fill in ? if unsure) |
Wildcards
Generally, all values and all forms of the cron expression support wildcards.
| / | Meaning |
|---|---|
| * | Any. For example, putting it in the month field means every month |
| / | Step; the first value is the starting time, the second is the divisor. For example, putting 1-20 in the seconds field cycles through 1, 21, 41, 1, 21, 41 and so on |
| - | Range; the first value is the start, the second is the end. For example, putting 1-4 in the month field means the four months 1, 2, 3, 4 |
| , | Enumeration. For example, putting 4,6,7,8 in the month field means the four months 4, 6, 7, 8 |