Whether you are scheduling backups, automating deployments, or running periodic cleanup scripts, cron is the backbone of task scheduling on Unix/Linux systems. This cheat sheet gives you 50+ copy-paste cron expression examples organized by frequency, plus crontab commands, platform differences, and common gotchas.
1. Cron Expression Syntax
A standard cron expression consists of 5 fields separated by spaces. Each field controls when the job runs:
┌───────────── 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, 0 and 7 = Sunday)
│ │ │ │ │
* * * * * command_to_executeThe command to execute follows the five fields. Use our Cron Generator tool to build expressions visually.
2. Special Characters Explained
Cron uses four special characters to define schedules beyond fixed values:
| Character | Meaning | Example | Description |
|---|---|---|---|
| * | Matches every possible value for the field | * * * * * | Every minute |
| , | Specifies a list of values (e.g., 1,3,5) | 0 9 * * 1,3,5 | Mon, Wed, Fri at 9 AM |
| - | Defines an inclusive range (e.g., 1–5 means 1 through 5) | 0 9 * * 1-5 | Mon through Fri at 9 AM |
| / | Defines a step interval (e.g., */5 means every 5 units) | */10 * * * * | Every 10 minutes |
3. 50+ Cron Expression Examples
The tables below cover the most commonly needed cron schedules. Each expression is ready to copy and paste into your crontab.
Every X Minutes
| Expression | Description | Next Run Example |
|---|---|---|
| * * * * * | Every minute | 10:00, 10:01, 10:02 ... |
| */1 * * * * | Every minute (explicit) | 10:00, 10:01, 10:02 ... |
| */2 * * * * | Every 2 minutes | 10:00, 10:02, 10:04 ... |
| */5 * * * * | Every 5 minutes | 10:00, 10:05, 10:10 ... |
| */10 * * * * | Every 10 minutes | 10:00, 10:10, 10:20 ... |
| */15 * * * * | Every 15 minutes | 10:00, 10:15, 10:30, 10:45 |
| */20 * * * * | Every 20 minutes | 10:00, 10:20, 10:40 ... |
| */30 * * * * | Every 30 minutes | 10:00, 10:30, 11:00 ... |
| 0,15,30,45 * * * * | At 0, 15, 30, 45 minutes past each hour | 10:00, 10:15, 10:30, 10:45 |
Hourly Schedules
| Expression | Description | Next Run Example |
|---|---|---|
| 0 * * * * | Every hour (at minute 0) | 10:00, 11:00, 12:00 ... |
| 30 * * * * | Every hour at minute 30 | 10:30, 11:30, 12:30 ... |
| 15 * * * * | Every hour at minute 15 | 10:15, 11:15, 12:15 ... |
| 0 */2 * * * | Every 2 hours | 00:00, 02:00, 04:00 ... |
| 0 */3 * * * | Every 3 hours | 00:00, 03:00, 06:00 ... |
| 0 */4 * * * | Every 4 hours | 00:00, 04:00, 08:00 ... |
| 0 */6 * * * | Every 6 hours | 00:00, 06:00, 12:00, 18:00 |
| 0 */8 * * * | Every 8 hours | 00:00, 08:00, 16:00 |
| 0 */12 * * * | Every 12 hours | 00:00, 12:00 |
Daily Schedules
| Expression | Description | Next Run Example |
|---|---|---|
| 0 0 * * * | Daily at midnight (00:00) | Tomorrow 00:00 |
| 0 1 * * * | Daily at 1:00 AM | Tomorrow 01:00 |
| 0 6 * * * | Daily at 6:00 AM | Tomorrow 06:00 |
| 30 7 * * * | Daily at 7:30 AM | Tomorrow 07:30 |
| 0 9 * * * | Daily at 9:00 AM | Tomorrow 09:00 |
| 30 8 * * * | Daily at 8:30 AM | Tomorrow 08:30 |
| 0 12 * * * | Daily at noon (12:00) | Tomorrow 12:00 |
| 0 15 * * * | Daily at 3:00 PM | Tomorrow 15:00 |
| 0 18 * * * | Daily at 6:00 PM | Tomorrow 18:00 |
| 0 23 * * * | Daily at 11:00 PM | Tomorrow 23:00 |
| 0 8-17 * * * | Every hour from 8 AM to 5 PM | 08:00, 09:00 ... 17:00 |
| 0 9,12,18 * * * | Three times a day (9 AM, noon, 6 PM) | 09:00, 12:00, 18:00 |
Weekly Schedules
| Expression | Description | Next Run Example |
|---|---|---|
| 0 9 * * 1 | Every Monday at 9:00 AM | Next Monday 09:00 |
| 0 9 * * 1-5 | Weekdays (Mon-Fri) at 9:00 AM | Next weekday 09:00 |
| 0 0 * * 0 | Every Sunday at midnight | Next Sunday 00:00 |
| 0 0 * * 6,0 | Saturday & Sunday at midnight | Next Sat/Sun 00:00 |
| 0 17 * * 5 | Every Friday at 5:00 PM | Next Friday 17:00 |
| 0 9 * * 1,3,5 | Mon, Wed, Fri at 9:00 AM | Next Mon/Wed/Fri 09:00 |
| 0 8-17 * * 1-5 | Hourly 8AM–5PM, weekdays only | Next weekday 08:00 |
| 30 6 * * 1-5 | Weekdays at 6:30 AM | Next weekday 06:30 |
Monthly Schedules
| Expression | Description | Next Run Example |
|---|---|---|
| 0 0 1 * * | 1st of every month at midnight | Next month, 1st 00:00 |
| 0 0 15 * * | 15th of every month at midnight | Next 15th 00:00 |
| 0 9 1 * * | 1st of every month at 9:00 AM | Next month, 1st 09:00 |
| 0 0 1,15 * * | 1st and 15th at midnight | Next 1st or 15th 00:00 |
| 0 0 * * 5L | Last Friday of the month (non-std) | Last Fri 00:00 |
| 0 9 * * 1#1 | First Monday of the month (non-std) | First Mon 09:00 |
| 0 0 28 * * | 28th of every month at midnight | Next 28th 00:00 |
Yearly / Quarterly Schedules
| Expression | Description | Next Run Example |
|---|---|---|
| 0 0 1 1 * | January 1st at midnight | Jan 1 00:00 |
| 0 0 1 1,4,7,10 * | Quarterly: Jan, Apr, Jul, Oct 1st | Next quarter 00:00 |
| 0 0 1 1,7 * | Bi-annually: Jan 1 & Jul 1 | Jan 1 or Jul 1 00:00 |
| 0 0 25 12 * | December 25th at midnight | Dec 25 00:00 |
| 0 0 1 */3 * | Every 3 months on the 1st | Next 1st in 3 months |
| 0 0 1 */6 * | Every 6 months on the 1st | Next 1st in 6 months |
Business & DevOps Schedules
| Expression | Description | Next Run Example |
|---|---|---|
| 0 2 * * * | Database backup at 2:00 AM daily | Tomorrow 02:00 |
| 0 3 * * 0 | Log rotation every Sunday at 3 AM | Next Sunday 03:00 |
| 0 4 1 * * | Monthly DB cleanup on 1st at 4 AM | Next month, 1st 04:00 |
| 0 1 * * * | SSL cert check daily at 1 AM | Tomorrow 01:00 |
| */5 * * * * | Health check every 5 minutes | 10:00, 10:05, 10:10 ... |
| 0 5 * * 1-5 | Deploy window: weekdays at 5 AM | Next weekday 05:00 |
| 0 0 * * * | Rotate logs daily at midnight | Tomorrow 00:00 |
| 0 */4 * * * | Send report digest every 4 hours | 00:00, 04:00, 08:00 ... |
| 0 22 * * 5 | Friday night maintenance at 10 PM | Next Friday 22:00 |
| 30 2 * * * | Temp file cleanup at 2:30 AM daily | Tomorrow 02:30 |
4. Crontab Commands Quick Reference
The crontab command manages per-user cron job files. Here are the essential commands:
| Command | What It Does |
|---|---|
| crontab -e | Edit your crontab file (opens in default editor) |
| crontab -l | List all cron jobs for the current user |
| crontab -r | Remove all cron jobs for the current user (use with caution!) |
| crontab -u alice -l | List cron jobs for a specific user (requires root) |
| crontab -u alice -e | Edit crontab for a specific user (requires root) |
| crontab filename | Install a crontab from a file (overwrites existing) |
# Edit crontab
crontab -e
# List all cron jobs
crontab -l
# Backup current crontab to a file
crontab -l > my-crontab-backup.txt
# Install crontab from a file
crontab my-crontab-backup.txt
# Remove all cron jobs (careful!)
crontab -r5. Platform-Specific Cron Syntax
Cron syntax varies slightly across platforms. Here are the key differences you need to know:
5 fields: minute hour day month weekday. The original and most common format.
# Standard 5-field crontab
*/5 * * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1Standard 5 fields in schedule.cron. Always runs in UTC. Minimum interval: 5 minutes.
# .github/workflows/scheduled.yml
on:
schedule:
- cron: '0 9 * * 1-5' # Weekdays 9AM UTC6 fields (adds year). Uses ? for day-of-week or day-of-month. Wrapped in cron().
# AWS EventBridge (6 fields, note the ?)
cron(0 9 ? * MON-FRI *) # Weekdays 9AM UTCStandard 5 fields in the schedule spec. Timezone support added in K8s 1.27+ via timeZone.
# Kubernetes CronJob spec
apiVersion: batch/v1
kind: CronJob
metadata:
name: daily-backup
spec:
schedule: "0 2 * * *"
timeZone: "America/New_York" # K8s 1.27+Standard 5 fields in vercel.json. Runs in UTC. Hobby plan: max 2 cron jobs, 1/day minimum.
// vercel.json
{
"crons": [{
"path": "/api/cron/daily-report",
"schedule": "0 9 * * *"
}]
}6. Cron Expression Gotchas
These are the most common mistakes developers make with cron schedules:
Cron runs in the system timezone by default. CI/CD platforms (GitHub Actions, Vercel) use UTC. Always check which timezone your cron daemon uses.
If a job takes longer than the interval (e.g., a 10-minute job on a 5-minute schedule), you get overlapping runs. Use flock or a PID lock file to prevent this.
When clocks spring forward, a job scheduled at the skipped hour will not run. When clocks fall back, it may run twice. Use UTC to avoid this.
In standard cron, if both day-of-month and day-of-week are set (not *), the job runs when EITHER matches — not both. This is a common source of confusion.
Standard cron does not support seconds. The minimum resolution is 1 minute. For sub-minute scheduling, use a loop with sleep inside a cron job.
Cron jobs run with a minimal environment. Your $PATH may not include expected binaries. Always use full paths in cron commands.
# Gotcha: overlapping runs - use flock to prevent
*/5 * * * * /usr/bin/flock -n /tmp/myjob.lock /path/to/script.sh
# Gotcha: environment - always use full paths
0 2 * * * /usr/bin/python3 /home/user/scripts/backup.py >> /var/log/backup.log 2>&1
# Gotcha: 30-second workaround (two entries)
* * * * * /path/to/script.sh
* * * * * sleep 30 && /path/to/script.sh
# Gotcha: PATH not set - define it at the top of your crontab
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Gotcha: percent signs (%) must be escaped in crontab
# Wrong:
0 0 * * * echo "Today is $(date +%Y-%m-%d)"
# Correct:
0 0 * * * echo "Today is $(date +\%Y-\%m-\%d)"Sample Crontab File
Here is a complete, real-world crontab file combining several patterns discussed above:
# =============================================
# Crontab for: webserver (production)
# Last updated: 2025-01-15
# =============================================
# Environment
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAILTO="ops-team@example.com"
# --- BACKUPS ---
# Full database backup at 2:00 AM daily
0 2 * * * /usr/bin/flock -n /tmp/db-backup.lock /opt/scripts/db-backup.sh >> /var/log/db-backup.log 2>&1
# Incremental file backup every 6 hours
0 */6 * * * /opt/scripts/file-backup.sh >> /var/log/file-backup.log 2>&1
# --- MAINTENANCE ---
# Clear temp files older than 7 days, daily at 3 AM
0 3 * * * /usr/bin/find /tmp -type f -mtime +7 -delete
# Rotate application logs every Sunday at 4 AM
0 4 * * 0 /opt/scripts/rotate-logs.sh >> /var/log/log-rotation.log 2>&1
# --- MONITORING ---
# Health check every 5 minutes
*/5 * * * * /opt/scripts/healthcheck.sh > /dev/null 2>&1
# SSL certificate expiry check daily at 6 AM
0 6 * * * /opt/scripts/check-ssl.sh
# Disk space alert if usage > 90%, every hour
0 * * * * /opt/scripts/disk-alert.sh
# --- REPORTS ---
# Send daily summary at 8 AM on weekdays
0 8 * * 1-5 /opt/scripts/daily-report.sh
# Monthly analytics report on the 1st at 9 AM
0 9 1 * * /opt/scripts/monthly-report.sh7. Testing and Debugging Cron
Before deploying a cron job to production, verify that it does what you expect:
Paste your expression into our Cron Expression Parser to see the next 10 run times and a human-readable explanation.
On most Linux systems, cron logs appear in /var/log/syslog or /var/log/cron. Use grep CRON /var/log/syslog to filter.
Capture stdout and stderr to a log file for debugging. This prevents cron from sending mail for every execution.
Before committing to a monthly schedule, test with * * * * * (every minute) to make sure the script runs correctly, then change to the target schedule.
By default, cron emails output to the user. Set MAILTO="" at the top of your crontab to disable email, or set it to a real address for alerts.
# Redirect all output to a log file
0 2 * * * /path/to/backup.sh >> /var/log/cron-backup.log 2>&1
# Disable cron mail for this job
0 2 * * * /path/to/backup.sh > /dev/null 2>&1
# Set MAILTO at the top of crontab
MAILTO=""
# Or send to a real address
MAILTO="admin@example.com"
# Check cron logs on Debian/Ubuntu
grep CRON /var/log/syslog | tail -20
# Check cron logs on CentOS/RHEL
grep CRON /var/log/cron | tail -20
# On systems using journald (systemd)
journalctl -u cron --since "1 hour ago"
# Quick test: add a job that writes to a file
# Then check if the file gets updated
* * * * * echo "cron works: $(date)" >> /tmp/cron-test.log
# Verify your crontab was saved correctly
crontab -l | grep -v '^#'
# Check if cron daemon is running
systemctl status cron # Debian/Ubuntu
systemctl status crond # CentOS/RHELCommon Cron Debugging Checklist
| Check | How to Verify |
|---|---|
| Cron daemon running? | systemctl status cron (or crond) |
| Crontab saved? | crontab -l and look for your entry |
| Script executable? | chmod +x /path/to/script.sh |
| Full paths used? | Use which python3 to find full path |
| Output captured? | Add >> /tmp/debug.log 2>&1 |
| Permissions correct? | Script owner = crontab owner |
| No syntax errors? | bash -n /path/to/script.sh |
| Timezone correct? | timedatectl or date to check |
Build and test your cron expressions interactively:
8. Frequently Asked Questions
What is the format of a cron expression?
A standard cron expression has 5 fields separated by spaces: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-7). For example, "0 9 * * 1-5" means every weekday at 9:00 AM.
What does */5 mean in cron?
The */5 syntax means "every 5 units" for the given field. In the minute field, */5 * * * * runs every 5 minutes (at 0, 5, 10, 15, ... 55). In the hour field, 0 */5 * * * runs every 5 hours at minute 0.
How do I run a cron job every 30 seconds?
Standard cron does not support sub-minute intervals. The workaround is to create two cron entries: one for the top of the minute and one with a 30-second sleep: * * * * * /path/to/script.sh and * * * * * sleep 30 && /path/to/script.sh
What is the difference between cron and crontab?
Cron is the background daemon (service) that executes scheduled tasks. Crontab (cron table) is the file that lists the scheduled jobs and their timing. You use the "crontab" command to edit, list, or remove your personal cron table.
Can I use cron on Windows?
Native Windows does not have cron. The equivalent is Task Scheduler (schtasks.exe). However, if you use WSL (Windows Subsystem for Linux), you can use cron normally. Docker containers on Windows also support cron.