Crontab Timing Format: Complete Guide with Examples
If you've ever needed to automate a task on a Linux or Unix server — running a backup every night, sending a report every Monday morning, or clearing log files every hour — you've encountered the crontab timing format. This guide explains every part of a cron expression, covers all special characters, and gives you practical, copy-paste examples for the most common scheduling needs.
When you're ready to build your own schedule visually, use our free Cron Expression Generator — it translates your expression to plain English and shows upcoming run times, all in your browser.
What is a Cron Job?
A cron job is a scheduled task managed by the cron daemon on Unix-like operating systems (Linux, macOS, BSD). The daemon reads the crontab (cron table) — a configuration file where each line defines a command and the schedule on which to run it. Cron jobs are used by developers and system administrators for:
- Automated database backups
- Log rotation and cleanup
- Sending scheduled emails or reports
- Syncing files with remote servers
- Running CI/CD health checks
- Clearing caches on a schedule
The 5-Field Crontab Timing Format
Every cron job starts with a 5-field expression followed by the command to execute. The fields, in order, are:
* * * * * command_to_execute
│ │ │ │ │
│ │ │ │ └── Day of week (0–6) │ 0 = Sunday, 6 = Saturday
│ │ │ └───── Month (1–12)
│ │ └──────── Day of month (1–31)
│ └─────────── Hour (0–23)
└────────────── Minute (0–59)
Each field can hold a single value, a range, a list, a step, or the wildcard *. The table below summarizes the valid ranges:
| Field | Allowed Values | Description |
|---|---|---|
| Minute | 0 – 59 | The minute of the hour |
| Hour | 0 – 23 | The hour of the day (24-hour clock) |
| Day of Month | 1 – 31 | The day of the month |
| Month | 1 – 12 | The month of the year |
| Day of Week | 0 – 6 | 0 = Sunday, 1 = Monday … 6 = Saturday |
Crontab Special Characters Explained
Understanding the four special characters is the key to mastering the crontab timing format:
* — Wildcard (Every)
An asterisk means "every possible value" for that field. * * * * * runs the job every single minute.
/ — Step Values
The slash defines a step. */5 in the minute field means "every 5 minutes" (at 0, 5, 10, 15 … 55). */2 in the hour field means "every 2 hours".
- — Ranges
A hyphen defines a range. 9-17 in the hour field means "every hour from 9 AM to 5 PM". 1-5 in the day-of-week field means Monday through Friday.
, — Lists
A comma separates specific values. 0,15,30,45 in the minute field means "at minutes 0, 15, 30, and 45" — effectively every 15 minutes.
Crontab Schedule Examples
Here are the most common crontab schedule examples you can copy and use directly:
| Expression | Meaning |
|---|---|
* * * * * | Every minute |
*/5 * * * * | Every 5 minutes |
*/15 * * * * | Every 15 minutes |
*/30 * * * * | Every 30 minutes |
0 * * * * | Every hour (at :00) |
0 */2 * * * | Every 2 hours |
0 */12 * * * | Every 12 hours (midnight & noon) |
0 0 * * * | Every day at midnight |
0 9 * * * | Every day at 9:00 AM |
0 9 * * 1 | Every Monday at 9:00 AM |
0 9 * * 1-5 | Weekdays (Mon–Fri) at 9:00 AM |
0 0 * * 0 | Every Sunday at midnight |
0 0 1 * * | First day of every month at midnight |
0 0 1 1 * | January 1st at midnight (yearly) |
0 0,12 * * * | Every day at midnight and noon |
30 8 * * 1-5 | Weekdays at 8:30 AM |
0 6 * * * | Every day at 6:00 AM |
0 23 * * * | Every day at 11:00 PM |
How to Edit Crontab (crontab -e)
The standard way to manage cron jobs on Linux is through the crontab -e command. Here's the full workflow:
Step 1: Open the Crontab Editor
crontab -e
This opens your personal crontab file in the system's default editor (usually nano on Ubuntu/Debian or vi on CentOS/RHEL).
Step 2: Add a Cron Job
Each line follows the format: [timing] [command]. For example, to back up a database every day at 2:00 AM:
0 2 * * * /usr/bin/mysqldump -u root mydb > /backups/mydb_$(date +\%F).sql
Step 3: Save and Exit
In nano, press Ctrl+O then Enter to save, and Ctrl+X to exit. The cron daemon automatically picks up the changes — no restart needed.
Useful Crontab Commands
| Command | Description |
|---|---|
crontab -e | Edit the crontab for the current user |
crontab -l | List all cron jobs for the current user |
crontab -r | Remove all cron jobs for the current user |
crontab -u username -l | List cron jobs for a specific user (root only) |
sudo systemctl status cron | Check if the cron daemon is running |
Common Crontab Configurations
Beyond manual scheduling, many Linux systems include predefined crontab configuration directories that run scripts automatically:
/etc/cron.hourly/— Scripts placed here run every hour/etc/cron.daily/— Scripts run once a day (usually at 6:25 AM)/etc/cron.weekly/— Scripts run once a week (usually Sunday)/etc/cron.monthly/— Scripts run once a month/etc/crontab— The system-wide crontab (has an extra user field)
Crontab Timing Tips & Common Mistakes
- Day of week vs Day of month: If you set both a day-of-month and a day-of-week, the job runs when either condition is true (OR logic), not both.
- Percent signs: In crontab, a literal
%in a command must be escaped as\%, otherwise cron treats it as a newline. - PATH issues: Cron jobs run with a minimal
PATH. Always use absolute paths to commands (e.g.,/usr/bin/python3not justpython3). - Testing: Use the
@rebootspecial string to run a job once at system startup, which is useful for testing. Other shortcuts include@hourly,@daily,@weekly,@monthly, and@yearly. - Logging: Redirect output to a log file to debug jobs:
0 * * * * /path/script.sh >> /var/log/myjob.log 2>&1
Build Your Cron Expression Visually
Manually writing and verifying crontab expressions is tedious. Use our free Cron Expression Generator to:
- Select timing using simple dropdowns
- See a plain-English description of your schedule instantly
- Preview the next 5 upcoming run times
- Copy the expression with one click
Everything runs 100% in your browser — no data is sent to any server.
Conclusion
The crontab timing format is a powerful 5-field syntax that every Linux developer and system administrator should know. Once you understand wildcards, ranges, lists, and steps, you can automate virtually any recurring task on your server. For quick expression building without memorizing syntax, our visual Cron Generator is always available — free, private, and instant.