ReferenceMarch 15, 20263 min read

Cron Expressions Explained: Schedule Tasks Like a Pro

Cron syntax is the standard for scheduling recurring tasks on servers, CI/CD pipelines, and cloud functions. Learn the five-field format with practical examples.

What Cron Does

Cron is the task scheduler built into Unix and Linux systems. It runs commands automatically at specified times — every minute, every day at midnight, every Monday at 9 AM, on the first of each month, or any other repeating schedule you can describe.

The schedule is defined by a cron expression — five fields that specify when the task should run:

`

│ │ │ │ │

│ │ │ │ └── Day of week (0-7, where 0 and 7 are Sunday)

│ │ │ └──── Month (1-12)

│ │ └────── Day of month (1-31)

│ └──────── Hour (0-23)

└────────── Minute (0-59)

`

Reading Cron Expressions

Each field accepts specific values:

A number means "at exactly this value." 30 14 * means "at 14:30 (2:30 PM) every day."

An asterisk () means "every possible value." means "every minute of every hour of every day."

A comma lists multiple values. 0 9,12,17 * means "at 9:00, 12:00, and 17:00 every day."

A hyphen defines a range. 0 9-17 * means "at the top of every hour from 9:00 through 17:00."

A slash defines intervals. /15 means "every 15 minutes." 0 /2 * means "every 2 hours at minute 0."

Practical Examples

Every day at midnight: 0 0 *

Minute 0, hour 0, every day, every month, every weekday.

Every weekday at 9 AM: 0 9 1-5

Monday (1) through Friday (5).

Every 5 minutes: /5 *

The slash means "every 5th minute."

First day of every month at 6 AM: 0 6 1

Day-of-month = 1.

Every Sunday at 3:30 PM: 30 15 0

Minute 30, hour 15, day-of-week 0 (Sunday).

Every 30 minutes during business hours on weekdays: 0,30 9-17 1-5

Minutes 0 and 30, hours 9 through 17, Monday through Friday.

Quarterly (first day of Jan, Apr, Jul, Oct) at midnight: 0 0 1 1,4,7,10 *

Common Cron Mistakes

Forgetting that hours are 0-23, not 1-24. Midnight is 0, not 24. Noon is 12.

Confusing day-of-week numbering. Sunday is 0 (or 7 on some systems). Monday is 1. Check your system's documentation.

Running too frequently. * runs every single minute. For a resource-intensive task, this can overload a server. Always consider whether the frequency is appropriate.

Not accounting for time zones. Cron uses the server's local time zone. A server in UTC running a job at 0 9 * fires at 9:00 UTC, which is 4:00 AM Eastern or 1:00 AM Pacific.

Where Cron Expressions Are Used

Beyond traditional Unix cron, the same syntax is used by:

  • CI/CD pipelines (GitHub Actions, GitLab CI) for scheduled builds
  • Cloud schedulers (AWS CloudWatch Events, Google Cloud Scheduler)
  • Task queues (Celery, Sidekiq) for recurring background jobs
  • Monitoring tools for periodic health checks
  • Database systems for scheduled backups and maintenance

How to Use the Toobits Cron Generator

Build cron expressions visually by selecting the schedule you want — the tool generates the correct expression and shows the next several execution times so you can verify the schedule is right. Alternatively, paste an existing cron expression to see a human-readable description of when it runs. Everything runs in your browser.

Try These Tools

Related Articles