What is a cron expression?
Cron runs commands on a schedule, and each line of a crontab file is one job: five time fields, then the command. A field can be * (every value), a number, a range like 1-5, or a list like 1,15. The job runs in every minute that matches all five.
| Field | Allowed values |
|---|---|
| Minute | 0 – 59 |
| Hour | 0 – 23 |
| Day of month | 1 – 31 |
| Month | 1 – 12 |
| Day of week | 0 – 6 |
Source The Open Group · POSIX.1-2024, crontab ↗
How to read a cron expression
Here it is with your numbers:
- Minute:
0means 0. - Hour:
9means 9. - Day of month:
*means every day of month. - Month:
*means every month. - Day of week:
1-5means Mon, Tue, Wed, Thu, Fri.
It means: at 9:00 AM, Monday through Friday. Times are in UTC.
Times here are in Coordinated Universal Time (UTC). Cron itself uses the clock of the computer it runs on (on Linux a crontab can set CRON_TZ), so if that computer isn’t on UTC, shift the times by its offset.
Source man7.org · crontab(5), Linux manual page ↗
Cron expression examples
| Expression | Runs |
|---|---|
| */5 * * * * | Every 5 minutes |
| 0 * * * * | At minute 0 past every hour |
| 0 0 * * * | At 12:00 AM |
| 0 9 * * 1-5 | At 9:00 AM, Monday through Friday |
| */15 9-17 * * 1-5 | Every 15 minutes during every hour from 9 AM through 5 PM, Monday through Friday |
| 30 4 1,15 * 5 | At 4:30 AM on the 1st and 15th of the month, plus every Friday |
| 0 0 1 * * | At 12:00 AM on the 1st of the month |
| 0 0 * * 0 | At 12:00 AM every Sunday |
| 0 0 1 1 * | At 12:00 AM on January 1 |
| 0 22 * * 1-5 | At 10:00 PM, Monday through Friday |
When both day fields are set
If the day of month and the day of week are both set, a day that matches either one runs the job. So 0 0 1,15 * 1 runs on the 1st and 15th of every month and on every Monday. To pick days by one field only, put * in the other: 0 0 * * 1 runs only on Mondays. On Linux, a field that contains a *, such as */2, counts as unset for this rule.
The month always has to match on Linux cron, and this tool works the same way. POSIX’s wording, read strictly, would let a day of the week match in any month when the month and day of week are set; Linux describes the month as always required.
Steps, names and @daily
POSIX defines only *, numbers, ranges and lists. Steps (*/5, 0-30/10), three-letter names (mon, jan), 7 for Sunday and nicknames are extensions documented for Linux cron; the pill on the result says “POSIX cron” when a schedule uses none of them. The nicknames are @yearly (or @annually, 0 0 1 1 *), @monthly (0 0 1 * *), @weekly (0 0 * * 0), @daily (0 0 * * *), @hourly (0 * * * *) and @reboot, which runs once when cron starts.
FAQs
What is a cron expression?
The schedule part of a crontab line: five fields for minute, hour, day of month, month and day of week, followed by the command to run. Each field is *, a number, a range like 1-5, or a list like 1,15.
How to write cron expression for every 5 minutes?
*/5 * * * *. The step */5 in the minute field means minutes 0, 5, 10 … 55. Steps are a Linux extension; on a strictly POSIX cron, list the minutes: 0,5,10,15,20,25,30,35,40,45,50,55 * * * *.
What is */5 in cron?
A step: every 5th value of the field, starting from its first value. In the minute field that is 0, 5, 10 … 55; in the hour field, 0, 5, 10, 15 and 20. A step can also follow a range: 0-30/10 is 0, 10, 20 and 30.
What does */2 mean in cron?
Every other value: in the hour field, */2 is 0, 2, 4 … 22, so the job runs every two hours. Steps restart each day, so */23 in the hour field means hours 0 and 23, not every 23 hours.
What does * mean in cronjob?
Every allowed value of that field: * in the hour field is every hour from 0 to 23. In the day fields, * also matters for the day rule: when neither day field is *, a day matching either one runs the job.
Does a cron expression have 5 or 6 fields?
Five time fields. POSIX counts the command as the sixth field of a crontab line. The Linux system crontab (/etc/crontab) also puts a user name between the five fields and the command.