Home/Blog/How to Read Cron Expressions: A Step-by-Step Guide
Web Development

How to Read Cron Expressions: A Step-by-Step Guide

Master the art of reading cron expressions with this practical guide. Learn to decode each field, understand common patterns, and translate cryptic scheduling strings into plain English.

By Inventive HQ Team
How to Read Cron Expressions: A Step-by-Step Guide

Cron expressions can look intimidating at first glance. A string like 0 9 * * 1-5 might seem cryptic, but it's actually a precise and elegant way to say "every weekday at 9:00 AM." Once you understand the pattern, reading cron expressions becomes second nature.

The Five-Field Foundation

Every standard cron expression consists of exactly five fields, each separated by a space. Think of these fields as answering five questions about when a task should run:

  1. Which minute? (0-59)
  2. Which hour? (0-23)
  3. Which day of the month? (1-31)
  4. Which month? (1-12)
  5. Which day of the week? (0-7, where 0 and 7 are Sunday)

The key to reading cron expressions is to process these fields from left to right, building up a complete picture of the schedule.

Reading Your First Cron Expression

Let's start with a simple example:

30 14 * * *

Step 1: Look at the first field (minute) → 30 This means "at 30 minutes past the hour."

Step 2: Look at the second field (hour) → 14 This means "at hour 14," which is 2:00 PM in 24-hour format.

Step 3: Look at the third field (day of month) → * The asterisk means "every day of the month."

Step 4: Look at the fourth field (month) → * Again, asterisk means "every month."

Step 5: Look at the fifth field (day of week) → * Once more, asterisk means "every day of the week."

Translation: "At 2:30 PM every day."

Understanding the Asterisk

The asterisk (*) is the most common character you'll see in cron expressions. It's a wildcard that means "every possible value" for that field. Think of it as "don't care about this field" or "any value works."

If all five fields contain asterisks (* * * * *), the task runs every single minute. If only the minute field is asterisk (* 9 * * *), the task runs every minute during the 9:00 AM hour.

Decoding Number Ranges

When you see a hyphen, it defines a range of values:

0 9 * * 1-5

The 1-5 in the day of week field means "Monday through Friday." Days of the week are numbered from 0 (Sunday) through 6 (Saturday), with 7 also representing Sunday for compatibility.

Translation: "At 9:00 AM, every day, every month, Monday through Friday" or more naturally, "At 9:00 AM on weekdays."

Another example:

0 8-17 * * *

The 8-17 in the hour field means hours 8 through 17 (8:00 AM through 5:00 PM).

Translation: "Every hour from 8:00 AM to 5:00 PM."

Reading Multiple Values with Commas

Commas let you specify multiple discrete values:

0 9,12,15 * * *

The 9,12,15 in the hour field means "hours 9, 12, and 15."

Translation: "At 9:00 AM, 12:00 PM, and 3:00 PM every day."

You can use commas in any field:

30 14 1,15 * *

Translation: "At 2:30 PM on the 1st and 15th of every month."

This is particularly useful for specifying specific days:

0 6 * * 1,3,5

Translation: "At 6:00 AM on Monday, Wednesday, and Friday."

Understanding Step Values with Slashes

The slash character specifies intervals or step values. It answers the question: "How often should this repeat?"

*/5 * * * *

The */5 in the minute field means "every 5 minutes." Starting from 0, the task runs at minutes 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, and 55.

Translation: "Every 5 minutes, all day, every day."

The slash can be used with ranges too:

0 9-17/2 * * *

The 9-17/2 means "every 2 hours between 9:00 AM and 5:00 PM," so it runs at 9:00 AM, 11:00 AM, 1:00 PM, 3:00 PM, and 5:00 PM.

Translation: "Every 2 hours during business hours (9 AM to 5 PM)."

Another common pattern:

0 0 */2 * *

The */2 in the day field means "every 2 days."

Translation: "At midnight every other day."

Combining Special Characters

The real power comes from combining these characters:

*/15 8-17 * * 1-5

Let's break this down:

  • */15: Every 15 minutes
  • 8-17: During hours 8 AM through 5 PM
  • *: Every day of the month
  • *: Every month
  • 1-5: Monday through Friday

Translation: "Every 15 minutes during business hours on weekdays."

A more complex example:

0,30 9-17 * * 1-5
  • 0,30: At minute 0 and minute 30 (on the hour and half-hour)
  • 9-17: During hours 9 AM through 5 PM
  • *: Every day of the month
  • *: Every month
  • 1-5: Monday through Friday

Translation: "Every 30 minutes during 9 AM to 5 PM on weekdays."

Common Patterns You'll Encounter

Once you recognize these patterns, reading becomes much faster:

Every Minute: * * * * * Runs 1,440 times per day. Usually too frequent for most tasks.

Every Hour: 0 * * * * Runs at the top of every hour (XX:00).

Daily at Midnight: 0 0 * * * The most common pattern for daily tasks.

Daily at Specific Time: 30 2 * * * Daily at 2:30 AM, often used for maintenance windows.

Weekdays Only: 0 9 * * 1-5 Common for business-related tasks.

Weekly on Monday: 0 9 * * 1 Weekly reports or maintenance.

Monthly on First Day: 0 0 1 * * Monthly billing, reports, or cleanup tasks.

First Monday of Month: This actually requires a script, as cron can't express this directly.

Time Format Considerations

Remember that cron uses 24-hour format for hours:

  • 0 = Midnight (12:00 AM)
  • 6 = 6:00 AM
  • 12 = Noon (12:00 PM)
  • 18 = 6:00 PM
  • 23 = 11:00 PM

If you see 0 0 * * *, that's midnight, not noon. For noon, you'd use 0 12 * * *.

Day Confusion: Month vs. Week

One tricky aspect is when both day-of-month and day-of-week are specified (neither is an asterisk). In most cron implementations, the task runs when EITHER condition is met (OR logic, not AND).

For example:

0 9 1 * 1

This runs at 9:00 AM on:

  • The 1st of every month (regardless of day of week), OR
  • Every Monday (regardless of day of month)

This is often not what people expect! If you want "first Monday only," you typically need to use an asterisk for one field or handle it in your script.

Practice Reading Real-World Examples

Example 1: 0 */6 * * *

  • Minute: 0 (on the hour)
  • Hour: */6 (every 6 hours)
  • Translation: "Every 6 hours at the top of the hour" (runs at 12 AM, 6 AM, 12 PM, 6 PM)

Example 2: 45 23 * * 6

  • Minute: 45
  • Hour: 23 (11 PM)
  • Day of month: * (any)
  • Month: * (any)
  • Day of week: 6 (Saturday)
  • Translation: "At 11:45 PM every Saturday"

Example 3: 0 0 1,15 * *

  • Translation: "At midnight on the 1st and 15th of every month"

Example 4: */10 9-17 * * 1-5

  • Translation: "Every 10 minutes from 9 AM to 5 PM on weekdays"

Example 5: 0 2 * * 0

  • Translation: "At 2:00 AM every Sunday"

Tips for Getting Better at Reading Cron

Practice with a Tool: Use our Cron Expression Builder to see how expressions translate to plain English and when they'll run next.

Read from Left to Right: Always process fields in order: minute, hour, day, month, weekday. Don't skip around.

Start with Asterisks: Look for which fields are asterisks (wildcards) first. These tell you what the schedule DOESN'T care about.

Look for Special Characters: Identify slashes (intervals), commas (lists), and hyphens (ranges) to understand the complexity.

Verify with Examples: Think through several execution times to ensure your interpretation matches reality.

Consider Time Zones: Remember that cron runs in the server's time zone unless configured otherwise.

When to Use Tools vs. Reading Manually

While learning to read cron expressions is valuable, you don't always need to decode them manually. For quick verification or complex expressions, use automated tools that provide:

  • Plain English translations
  • Next several execution times
  • Visual calendars showing when tasks run
  • Validation that the syntax is correct

Our free Cron Expression Builder provides all these features, making it easy to both create and understand cron schedules without memorizing every syntax rule.

Whether you're debugging an existing cron job, reviewing a colleague's automation, or simply trying to understand when a scheduled task will run, the ability to read cron expressions is an essential skill for developers and system administrators. With practice, these five-field strings become as readable as plain English.

Need Expert IT & Security Guidance?

Our team is ready to help protect and optimize your business technology infrastructure.