Crontab Translator
Cron syntax is five fields of pure punctuation. Paste an expression like 0 4 * * 1 and see exactly when it runs — before your backup fires at the wrong time.
…
| Field | Value | Meaning |
|---|
Standard 5-field cron (Vixie cron, the one behind crontab -e on Linux and macOS): minute, hour, day of month, month, day of week. When both day fields are restricted, the job runs when either matches. Weekdays are 0–7 with both 0 and 7 meaning Sunday.
How cron expressions are read
A standard Linux crontab line uses five space-separated timing fields: minute (0–59), hour (0–23), day of month (1–31), month (1–12), and day of week (0–7, where 0 and 7 are Sunday). A wildcard * matches every value, commas specify lists (1,15), hyphens define ranges (1-5 for Monday–Friday), and slashes set step intervals (*/15 for every 15 minutes).
Watch out for a classic trap: putting * in the minute field (* 4 * * *) instead of 0 does not run once at 4:00 AM—it runs every single minute from 04:00 to 04:59, launching 60 overlapping backup jobs.
Step-by-step example: scheduling a weekly Sunday rsync backup
You want your off-site backup script /usr/local/bin/backup.sh to run every Sunday at 03:30 AM and log its output.
- Set minute to
30and hour to3. - Leave day-of-month and month as
*so it applies every week of the year. - Set day-of-week to
0(Sunday), producing30 3 * * 0. - Open your schedule with
crontab -eand add:30 3 * * 0 /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1.
Result: The script runs once a week at 03:30 AM Sunday, completely unattended, and writes stdout plus errors to a log file you can inspect.
Frequently Asked Questions
Why does my script work manually in bash but fail inside cron?
Cron runs with a minimal PATH (usually /usr/bin:/bin) and no interactive shell profile. Always use absolute paths to binaries and files, or declare PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin at the top of your crontab.
Should I use crontab -e or sudo crontab -e?
Use crontab -e for jobs owned by your regular user, such as pulling Docker images or syncing home folders. Use sudo crontab -e only when the command requires root privileges, like mounting system drives or restarting system services.
How do I know which timezone cron follows?
Cron follows the host operating system timezone shown by timedatectl. If your server still defaults to UTC, a 04:00 job runs at 06:00 CEST in Spain—either run sudo timedatectl set-timezone Europe/Madrid or adjust the hour accordingly.