Dev / IT7 min read

Cron Expression Guide: Schedule Jobs Like a Pro

Master cron syntax with this complete guide. Learn every field, special characters, common patterns, and how to schedule jobs on Linux, AWS, and Kubernetes.

What is a Cron Expression?

A cron expression is a string of five (or six) fields that define a schedule for recurring tasks. Cron is the time-based job scheduler in Unix-like systems. The name comes from the Greek word "chronos" (time).

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

Special Characters

CharacterMeaningExample
*Any value* * * * * — every minute
,List separator1,15,30 — at minutes 1, 15, and 30
-Range9-17 — hours 9 through 17
/Step values*/15 — every 15 units

Common Patterns

ExpressionMeaning
* * * * *Every minute
0 * * * *Every hour (at :00)
0 0 * * *Every day at midnight
0 0 * * 0Every Sunday at midnight
0 9 * * 1-5Every weekday at 9:00 AM
0 0 1 * *First day of every month at midnight
0 0 1 1 *January 1st at midnight (yearly)
*/15 * * * *Every 15 minutes
0 9,12,18 * * *At 9:00, 12:00, and 18:00 daily
0 0 * * 1Every Monday at midnight

Cron in Different Environments

Linux Crontab

# Edit crontab
crontab -e

# Backup database every day at 2 AM
0 2 * * * /scripts/backup-db.sh

# Clean temp files every Sunday at 3 AM
0 3 * * 0 /scripts/cleanup.sh

AWS EventBridge (CloudWatch Events)

AWS uses a 6-field cron with year field: cron(Minutes Hours Day Month Weekday Year)

# Every day at 10 AM UTC
cron(0 10 * * ? *)

# Every weekday at 8 AM
cron(0 8 ? * MON-FRI *)

Kubernetes CronJob

apiVersion: batch/v1
kind: CronJob
spec:
  schedule: "0 2 * * *"  # Every day at 2 AM

✓ Tip: Always test cron expressions before deploying to production. Use the FreeUtil Cron Builder to preview the next 8 run times and verify your expression does what you expect.

TRY THE FREE TOOL

Cron Expression Builder

Build cron expressions visually — see next run times

Open Tool →
← Back to all articles