The Shape of a Line
# m h dom mon dow command
30 2 * * * /usr/local/bin/backup.shThis job runs every day at 02:30. The fields are separated by spaces:
| Field | Values |
|---|---|
| Minute | 0-59 |
| Hour | 0-23 |
| Day of month | 1-31 |
| Month | 1-12 or jan-dec |
| Day of week | 0-7 or sun-sat |
In the day-of-week field, both 0 and 7 mean Sunday. Names use the first three letters and ignore case.
Ranges, Lists, and Steps
- Star:
*means every value of the field. - Range:
1-5in the day-of-week field means Monday to Friday. - List:
1,15in the day-of-month field means the 1st and the 15th. - Step:
*/15in the minute field means every 15 minutes;0-30/10means minutes 0, 10, 20, and 30.
The cron of Debian and Ubuntu does not accept names inside ranges or lists (cronie on AlmaLinux and Rocky Linux does), so use numbers there.
When Both Day Fields Are Set
If both day of month and day of week are restricted, the job runs when either one matches. 0 9 1 * 1 runs on the 1st of every month and on every Monday, not only on Mondays that fall on the 1st. To require both, put the second test in the command. This runs on the first Monday of the month:
0 9 1-7 * * [ "$(date +\%u)" = 1 ] && /usr/local/bin/report.shSpecial Strings
| String | Same as |
|---|---|
@reboot | Once at startup |
@hourly | 0 * * * * |
@daily | 0 0 * * * |
@weekly | 0 0 * * 0 |
@monthly | 0 0 1 * * |
@yearly | 0 0 1 1 * |
@midnight is the same as @daily, and @annually the same as @yearly. A special string replaces all five time fields.
Examples
| Line | Runs |
|---|---|
*/ | Every 5 minutes |
0 * * * * | Every hour |
0 */ | Every 6 hours |
0 3 * * * | 03:00 daily |
0 3 * * 0 | 03:00 on Sundays |
30 8 * * 1- | 08:30 on weekdays |
15 2 1, | 02:15, 1st and 15th |
0 0 1 * * | Midnight, 1st of month |
The most asked-for interval has its own guide: cron every 5 minutes.
Edit and List a Crontab
crontab -e
crontab -l
sudo crontab -u deploy -lcrontab -e opens your crontab in an editor and installs it when you save; jobs run as your user. A step-by-step example is in how to create a cron job.
The System Crontab Has a User Field
# in /etc/crontab or a file in /etc/cron.d/
0 4 * * * root /usr/local/bin/cleanup.shHere a sixth field, the user, comes before the command. A line copied from a personal crontab without it fails. On Debian and Ubuntu, cron ignores files in /etc/cron.d whose names contain a dot, so name them like cleanup, not cleanup.cron.
Percent Signs, PATH, and Output
- Percent signs: cron turns an unescaped
%into a new line. Write\%, as indate +\%F. - PATH: cron runs jobs with a short PATH, so use full paths or set PATH at the top of the crontab.
- Shell: jobs run with
/bin/sh, not bash, unless you set SHELL. - Output: redirect it to a log, or it is mailed to the user or lost.
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
0 2 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1The Time Zone
cron uses the server's time zone, which timedatectl shows. After you change it, restart the cron service (cron on Debian and Ubuntu, crond on AlmaLinux and Rocky Linux) so jobs follow the new zone; see how to change the time zone in Ubuntu. cronie on AlmaLinux and Rocky Linux also reads a CRON_
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations