Cron Expression Generator: Visual Crontab Schedule Builder
Cron Expression Generator: Visual Crontab Schedule Builder
What Is Cron and Why Do You Need It?
Cron is a time-based job scheduler in Unix-like computer operating systems (Linux, macOS). Users schedule jobs (commands or scripts) to run periodically at fixed times, dates, or intervals.
It powers:
- Automated backups (database dumps, file backups)
- System maintenance (log rotation, cache clearing)
- Periodic reports (daily emails, weekly analytics)
- Batch jobs (data processing, ETL tasks)
- Monitoring (health checks, uptime alerts)
But cron syntax is notoriously confusing:
0 9 * * 1 /path/to/backup.sh
What does this mean? Run every Monday at 9 AM? Or January 9th at 9 AM?
Stop guessing. Use the KNothing Cron Generator to build schedules visually.
Meet the KNothing Cron Expression Generator
The KNothing Cron Generator translates between:
- Human language → Cron syntax
- Cron syntax → Human language
- Visual interface → Cron expression
✅ Visual Builder
Click dropdowns to build cron expressions. No syntax memorization required.
✅ Real-Time Translation
See "Every Monday at 9 AM" instantly convert to 0 9 * * 1.
✅ Next Execution Preview
See the next 10 scheduled execution times. Verify your schedule before deploying.
✅ Presets
One-click schedules for common tasks:
- Every minute
- Every hour
- Daily at midnight
- Weekly on Monday
- Monthly on the 1st
Cron Syntax Explained (5-Part Format)
The Structure:
┌───────────── minute (0 - 59)
│ ┌─────────── hour (0 - 23)
│ │ ┌────────── day of month (1 - 31)
│ │ │ ┌───────── month (1 - 12)
│ │ │ │ ┌─────── day of week (0 - 7, 0 or 7 is Sunday)
│ │ │ │ │
* * * * *
Each Part Explained:
1. Minute (0 - 59)
When the job runs within the hour.
0 = At the start of the hour
15 = At 15 minutes past the hour
30 = At half past the hour
2. Hour (0 - 23)
When the job runs during the day.
0 = Midnight (12 AM)
9 = 9 AM
17 = 5 PM (24-hour format)
3. Day of Month (1 - 31)
Which day of the month to run.
1 = First day of the month
15 = 15th day of the month
* = Every day
4. Month (1 - 12)
Which month to run.
1 = January
6 = June
12 = December
* = Every month
5. Day of Week (0 - 7)
Which day of the week to run.
0 or 7 = Sunday
1 = Monday
5 = Friday
* = Every day
Special Characters
* (Asterisk) - Every
* = Every unit
* * * * * = Every minute of every day
, (Comma) - Multiple Values
0 9,17 * * * = At 9 AM and 5 PM every day
- (Hyphen) - Range
0 9-17 * * 1-5 = Every hour from 9 AM to 5 PM, Mon-Fri
/ (Slash) - Step
*/15 * * * * = Every 15 minutes
0 */2 * * * = Every 2 hours
Common Cron Examples
"Every Day at Midnight"
0 0 * * *
Translation: At minute 0 of hour 0 (midnight), every day.
"Every Monday at 9 AM"
0 9 * * 1
Translation: At minute 0 of hour 9 (9 AM), every Monday.
"Every 6 Hours"
0 */6 * * *
Translation: At minute 0, every 6 hours (midnight, 6 AM, noon, 6 PM).
"First Day of Every Month"
0 0 1 * *
Translation: At midnight on the 1st of every month.
"Weekdays at 8:30 AM"
30 8 * * 1-5
Translation: At 8:30 AM, Monday through Friday.
"Every 15 Minutes"
*/15 * * * *
Translation: Every 15 minutes (0, 15, 30, 45).
Real-World Use Cases
1. Daily Database Backup at 3 AM
0 3 * * * /usr/bin/pg_dump mydb > /backups/mydb_$(date +\%Y\%m\%d).sql
Cron: 0 3 * * *
2. Weekly Log Rotation (Every Sunday)
0 0 * * 0 /usr/sbin/logrotate /etc/logrotate.conf
Cron: 0 0 * * 0
3. Hourly API Health Check
0 * * * * curl -f https://api.example.com/health || echo "API down" | mail -s "Alert" [email protected]
Cron: 0 * * * *
4. Monthly Report (1st of Month at 9 AM)
0 9 1 * * /scripts/monthly_report.sh
Cron: 0 9 1 * *
5. Work Hours Only (Mon-Fri, 9 AM-5 PM)
0 9-17 * * 1-5 /scripts/work_hours_check.sh
Cron: 0 9-17 * * 1-5
Cron Conflicts: What If Both "Day of Month" AND "Day of Week" Are Specified?
The OR Behavior
If you specify both day of month AND day of week, cron runs when either matches:
0 0 15 * 1
This runs on:
- The 15th of the month
- Every Monday
Not "Monday the 15th" only.
Solution: Use One or the Other
Prefer day of week for periodic tasks:
0 9 * * 1 = Every Monday
Prefer day of month for date-specific tasks:
0 0 1 * * = First of every month
Cron Predefined Schedules
Instead of complex expressions, use shortcuts:
@yearly / @annually
@yearly = 0 0 1 1 *
Run once a year at midnight on January 1.
@monthly
@monthly = 0 0 1 * *
Run once a month at midnight on the first day.
@weekly
@weekly = 0 0 * * 0
Run once a week at midnight on Sunday.
@daily / @midnight
@daily = 0 0 * * *
Run once a day at midnight.
@hourly
@hourly = 0 * * * *
Run once an hour at the start of the hour.
@reboot
@reboot = (run at system startup)
Run once at system boot.
Troubleshooting Cron Jobs
❌ Problem: Job Didn't Run
Possible causes:
- Cron daemon not running
- Wrong permissions on script file
- Missing shebang (
#!/bin/bash) at top of script - Incorrect path (use absolute paths:
/usr/bin/python3notpython3)
Fix:
# Check cron is running
sudo systemctl status cron
# Check script permissions
chmod +x /path/to/script.sh
# Test manually first
/path/to/script.sh
❌ Problem: Job Ran at Wrong Time
Cause: Timezone confusion. Cron uses server timezone, not your local timezone.
Fix:
# Check server timezone
timedatectl
# Set timezone in crontab
CRON_TZ=America/New_York
0 9 * * * /path/to/script.sh
❌ Problem: No Output/Logs
Cause: Cron suppresses output by default.
Fix:
# Redirect output to log file
0 0 * * * /path/to/script.sh >> /var/log/myjob.log 2>&1
# Or email output
0 0 * * * /path/to/script.sh | mail -s "Cron output" [email protected]
Cron in Different Systems
Linux Cron (Traditional)
# Edit crontab
crontab -e
# List crontab
crontab -l
# System-wide cron
sudo nano /etc/crontab
Kubernetes CronJob
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup
spec:
schedule: "0 3 * * *" # Cron format
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: backup-image:latest
AWS EventBridge (CloudWatch Rules)
{
"scheduleExpression": "cron(0 3 * * ? *)"
}
Note: AWS uses slightly different syntax:
?instead of*for day of month or day of week- Year field is required
Why KNothing's Cron Generator?
🎯 Visual Builder
No syntax memorization. Click dropdowns to build schedules.
✅ Validation
Highlights invalid expressions before you deploy.
📅 Next Executions
See exactly when your job will run next.
🌐 Offline
Works without internet after first load. Perfect for servers.
🔒 Privacy
Your schedules aren't logged or tracked.
FAQ
What's the difference between * * * * * and */1 * * * *?
Both mean "every minute," but */1 is more explicit. Use * for simplicity.
Can I run a cron job every second?
No. Cron's minimum resolution is 1 minute. For seconds-level scheduling, use systemd timers or a custom loop script.
What if the 31st doesn't exist (Feb 30)?
Cron skips invalid dates. If you schedule "31st of every month," it runs on Jan 31, Mar 31, etc., but not Feb (no 31st).
How do I debug a cron job?
Add logging:
* * * * * echo "[$(date)] Cron test" >> /tmp/cron.log 2>&1
Check /tmp/cron.log to verify cron is working.
Stop Guessing Cron Syntax
Build schedules visually, validate instantly, and deploy with confidence.