CalquioCalquio

Search

Search for calculators and tools

Cron Expression Parser

Parse and validate cron expressions. See human-readable descriptions and next scheduled run times.

Format: minute hour day-of-month month day-of-week

You May Also Like

What is Cron?

Cron is a time-based job scheduler found in Unix-like systems. It lets you run commands or scripts automatically at specified times - like setting an alarm clock for your computer.

Named after the Greek word "chronos" (time), cron has been scheduling tasks since the 1970s and remains the standard way to automate recurring jobs.

Common uses:

  • Database backups at midnight
  • Sending weekly email reports
  • Cleaning up old files
  • Syncing data between systems
  • Monitoring and alerts

Cron Expression Syntax

A cron expression has 5 (or 6) fields:

┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6, Sun=0)
│ │ │ │ │
* * * * *

Special characters:

SymbolMeaningExample
*Any value* * * * * = every minute
,List1,15,30 = at 1, 15, and 30
-Range1-5 = 1 through 5
/Step*/15 = every 15

Common Cron Examples

🕐 Time-based:

ExpressionDescription
0 * * * *Every hour (at minute 0)
0 0 * * *Every day at midnight
0 9 * * *Every day at 9:00 AM
0 9 * * 1Every Monday at 9:00 AM
0 0 1 * *First day of every month

⏱️ Interval-based:

ExpressionDescription
*/5 * * * *Every 5 minutes
*/15 * * * *Every 15 minutes
0 */2 * * *Every 2 hours
0 0 */3 * *Every 3 days

📅 Complex schedules:

ExpressionDescription
0 9-17 * * 1-5Hourly, 9AM-5PM, Mon-Fri
0 0 1,15 * *1st and 15th of month
30 4 * * 04:30 AM every Sunday
0 22 * * 1-510 PM on weekdays

Memory trick: Think "minute, hour, day, month, weekday" - from smallest to largest time unit (mostly).

Special Strings

Many cron implementations support these shortcuts:

StringEquivalentDescription
@yearly0 0 1 1 *Once a year (Jan 1)
@monthly0 0 1 * *First of the month
@weekly0 0 * * 0Sunday at midnight
@daily0 0 * * *Every day at midnight
@hourly0 * * * *Every hour
@reboot-On system startup

Not all cron implementations support these shortcuts! Standard crontab on Linux does, but cloud schedulers may not. Always test your expressions.

Common Cron Mistakes

❌ Mistake 1: Forgetting the "at" vs "every"

# Wrong: Runs every minute of hour 9
* 9 * * *

# Right: Runs once at 9:00 AM
0 9 * * *

❌ Mistake 2: Day of week confusion

# Sunday = 0 (or 7 in some systems)
# Monday = 1
# Saturday = 6

❌ Mistake 3: Overlapping conditions

# This runs on the 15th AND on Fridays (OR logic!)
0 0 15 * 5

# Not just "15th if it's a Friday"

❌ Mistake 4: Time zone issues

  • Cron uses the system's timezone
  • UTC is safer for production servers
  • Be careful during daylight saving transitions

Cron Variants

Standard Unix Cron (5 fields)

* * * * * command

Extended Cron (6 fields - with seconds)

* * * * * * command
│
└── seconds (0-59)

Used by: Quartz (Java), Spring, node-cron

AWS CloudWatch (6 fields - with year)

* * * * * *
          │
          └── year (optional)

Kubernetes CronJob Uses standard 5-field format, but runs containers instead of commands.

Best Practices

🔧 For Reliability:

  • Always log your cron job output
  • Add error handling and notifications
  • Use lock files to prevent overlapping runs
  • Set timeouts for long-running jobs

📝 For Maintenance:

# Good: Document your crontabs
# Backup database every night at 2 AM
0 2 * * * /scripts/backup.sh

# Bad: No comments, hard to understand later
0 2 * * * /scripts/backup.sh

⏰ For Performance:

  • Avoid running heavy jobs at "round" times (many jobs run at midnight!)
  • Stagger jobs: use 3 0 * * * instead of 0 0 * * *
  • Consider system load and resource contention

🔒 For Security:

  • Use absolute paths in scripts
  • Don't store credentials in crontab
  • Run with minimum required permissions