FmtDev
Idioma
Back to blog
Ver antes de leer
Stop GUESSING Your Cron Jobs
Shorts

Stop GUESSING Your Cron Jobs

Watch on YouTube
March 18, 2026

Cron Job Syntax: Every Symbol & Field Explained

Learn cron job syntax with clear examples. Understand every field (minute, hour, day, month, weekday) and every symbol (*, /, -, ,) with 20+ real-world cron expression examples.

Cron Job Syntax Explained: Every Symbol, Every Field

A cron expression is a five-field string that defines when a scheduled task runs on a server. Each field represents minute, hour, day of month, month, and day of week. This comprehensive guide explains every field and symbol with examples.

Table of Contents

  1. The 5 Fields of a Cron Expression
  2. Every Symbol Explained
  3. 20 Real-World Cron Examples
  4. Common Cron Mistakes
  5. Cloud-Native Cron: AWS EventBridge vs Standard Cron
  6. Advanced Execution Intervals: The */2 Syntax
  7. How to Build and Test Cron Expressions
  8. FAQ

The 5 Fields of a Cron Expression

To master cron, you must first understand the "standard" 5-field format used by almost every Unix-like system. While some implementations (like Quartz or AWS EventBridge) add a 6th field for seconds or years, the core logic remains the same.

The syntax follows this structure:

* * * * *
| | | | |
| | | | day of week (0-7, Sunday = 0 or 7)
| | | month (1-12)
| | day of month (1-31)
| hour (0-23)
minute (0-59)

Detailed Field Breakdown

FieldRequiredAllowed ValuesAllowed Special Characters
MinuteYes0-59* , - /
HourYes0-23* , - /
Day of MonthYes1-31* , - /
MonthYes1-12 (or JAN-DEC)* , - /
Day of WeekYes0-7 (0 and 7 are Sunday)* , - /

Every Symbol Explained

Symbols are the logic gates of cron. They allow you to define ranges, intervals, and specific subsets of time.

1. The Asterisk (*) — "Every"

The asterisk is a wildcard. It matches every possible value for that field.

  • * * * * * means "run every minute, of every hour, of every day..."

2. The Comma (,) — "And"

Use the comma to separate a list of values.

  • 0 9,12,15 * * * means "run at exactly 9:00 AM, 12:00 PM, and 3:00 PM."

3. The Hyphen (-) — "Range"

Define a start and end range (inclusive).

  • 0 9-17 * * * means "run at the top of every hour between 9:00 AM and 5:00 PM."

4. The Slash (/) — "Step"

The slash defines increments. It is often combined with the asterisk (e.g., */5) to mean "every N units."

  • */5 * * * * means "run every 5 minutes (0, 5, 10, 15...)."
  • 0 0-23/2 * * * means "run every 2 hours."

20 Real-World Cron Examples

Using the symbols above, here are 20 of the most common cron expressions used in production systems today.

ExpressionMeaningTypical Use Case
* * * * *Every single minuteMonitoring, fast data syncing
0 * * * *Every hour (at minute 0)Database cleanup, logs rotation
0 0 * * *Every midnight (00:00)Full data backups, daily reports
0 0 * * 0Every Sunday at midnightWeekly maintenance, system updates
0 0 1 * *First day of every monthMonthly billing, invoice generation
0 9 * * 1-59:00 AM, Monday to FridayWarm up caches before work hours
*/5 * * * *Every 5 minutesSmall intervals, status checks
0 */2 * * *Every 2 hoursMedium-frequency data ingestion
30 18 * * *6:30 PM every dayEnd-of-day data snapshot
0 1 1 1 *Yearly (New Year's Day)Annual security audits
0 22 * * 1-510:00 PM, Mon-FriOff-peak processing (Weekdays)
0 0 * * 6,0Midnight on Sat and SunWeekend-only database indexing
*/15 9-17 * * *Every 15 min, during 9am-5pmHigh-traffic sync during business hours
0 12 * * *Every NoonMiddy synchronization
0 4 * * *4:00 AM every dayLow-traffic heavy task (e.g., reindexing)
0 1 * * 11:00 AM every MondayStart of week data reset
0 0 1-7 * 1First Monday of the MonthMonthly payroll or meeting prep
0 0 15 * *15th of the MonthMid-month performance review
45 23 * * *11:45 PM every dayFinal daily record consolidation
*/30 * * * *Every 30 minutesPeriodic file cleanup

Common Cron Mistakes

Even senior DevOps engineers make these mistakes. Here is what to watch out for:

1. Sunday Confusion (0 vs 7)

Historically, 0 was Sunday. Later implementations added 7 as Sunday for those who think of the week ending on Sunday. The Fix: Use 0 or 7 confidently (both work on almost all modern systems like Linux crontab).

2. The Day-of-Month OR Day-of-Week Problem

In cron, if both the Day of Month and Day of Week fields are specified (i.e., not *), it creates an OR logic, not an AND logic.

  • 0 0 1 * 1 means "Run on the 1st of the month OR every Monday." It will NOT run only on the 1st if it happens to be a Monday.

3. Timezone Differences

Servers usually run on UTC. If you set a task for 0 9 * * * expecting 9 AM local time, it might run at 4 AM local time depending on your offset. The Fix: Always verify your server time with date before setting a schedule.


Cloud-Native Cron: AWS EventBridge vs Standard Cron

If you are deploying scheduled tasks on AWS (Lambda triggers, Step Functions, ECS scheduled tasks), you are not using standard Unix cron — you are using AWS EventBridge Scheduler, which has a fundamentally different expression format.

The 6-Field EventBridge Format

EventBridge uses a 6-field system wrapped in a cron() function:

cron(Minutes Hours Day-of-month Month Day-of-week Year)

This differs from standard cron in three critical ways:

  1. Year field: EventBridge adds a 6th field for the year (use * for every year).
  2. The ? (question mark) wildcard: In EventBridge, you cannot use * for both Day-of-month and Day-of-week simultaneously. One of them MUST be ? — the "no specific value" character. This is the single most common cause of Parameter ScheduleExpression is not valid errors.
  3. Day-of-week mapping: EventBridge uses SUN-SAT or 1-7 where 1 = Sunday and 7 = Saturday. This is the opposite of standard Unix cron where 0 = Sunday. The EventBridge cron day-of-week field accepts both the SUN-SAT abbreviations and the 1-7 numeric range, but the numeric mapping catches developers off guard.

EventBridge vs Standard Cron Comparison

ScenarioStandard Cron (5-field)AWS EventBridge (6-field)
Every midnight0 0 * * *cron(0 0 * * ? *)
Every Sunday at 9 AM0 9 * * 0cron(0 9 ? * SUN *) or cron(0 9 ? * 1 *)
Every weekday at 6 PM0 18 * * 1-5cron(0 18 ? * MON-FRI *) or cron(0 18 ? * 2-6 *)
1st of every month0 0 1 * *cron(0 0 1 * ? *)
Every Saturday at noon0 12 * * 6cron(0 12 ? * SAT *) or cron(0 12 ? * 7 *)

Notice the pattern: when you specify a Day-of-week, the Day-of-month must be ?, and vice versa. This is a hard constraint enforced by the EventBridge API.

Valid EventBridge Expression: Every Day, Sunday Through Saturday

To run a task at 8:00 AM UTC every single day (covering Sunday through Saturday), the correct expression is:

cron(0 8 * * ? *)

Here, * is used for Day-of-month (every day), and ? is used for Day-of-week (no specific value). You can validate this using our Cron Expression Builder — though note that EventBridge's ? and year fields are extensions beyond standard cron.


Vixie Cron: Day of Month and Day of Week "OR" Semantics

A frequent point of confusion for developers involves Vixie cron day of month and day of week OR semantics. Vixie cron is the standard implementation used in most Linux distributions.

Unlike other fields which use "AND" logic, the Day-of-Month (field 3) and Day-of-Week (field 5) share a unique relationship. If you specify a value for both fields (meaning neither is *), Vixie cron will execute the command when EITHER field matches the current time.

For example, the expression 0 0 1,15 * 5 will run at midnight on the 1st and 15th of the month, AND every Friday. It does not mean "only on Fridays that fall on the 1st or 15th."


Advanced Execution Intervals: The */2 Syntax

One of the most commonly searched — and most commonly mistyped — cron patterns is the every-2-hours expression:

0 */2 * * *

Let us break this down precisely.

What 0 */2 * * * Means

This expression reads: "At minute 0, past every 2nd hour." In practice, this fires at 00:00, 02:00, 04:00, 06:00... all the way to 22:00, for a total of 12 executions per day.

The / character is the step value operator. When combined with *, it means "starting from the minimum value of this field, execute at every Nth interval." So */2 in the hour field means "every 2nd hour starting from hour 0."

Why Spacing Matters

Developers frequently search for 0*/2*** — a compressed version with no spaces. This will not work on any standard cron implementation. The five fields must be separated by whitespace. The cron daemon parses fields by splitting on spaces or tabs; without them, the entire string is interpreted as a single malformed field.

ExpressionValid?Meaning
0 */2 * * *✅ YesAt minute 0, every 2nd hour
0*/2***❌ NoSyntax error — unrecognized token
*/30 * * * *✅ YesEvery 30 minutes
0 0-23/2 * * *✅ YesEvery 2 hours (explicit range form)
0 */3 * * *✅ YesEvery 3 hours (00:00, 03:00, 06:00...)

Step Values Beyond *

The step operator is not limited to *. You can combine it with a range to create precise windows:

  • 0 9-17/2 * * * — Every 2 hours between 9 AM and 5 PM (09:00, 11:00, 13:00, 15:00, 17:00).
  • */10 0-5 * * * — Every 10 minutes, but only during midnight to 5 AM.
  • 0 */4 * * 1-5 — Every 4 hours, Monday through Friday only.

To instantly verify any of these patterns, paste them into our Cron Explainer for a plain-English translation.


How to Build and Test Cron Expressions

Manually calculating complex cron expressions is a recipe for disaster. Using a visual builder is significantly safer.

Step 1: Generate your Expression

Use our Cron Expression Builder. It provides a simple UI to toggle hours, minutes, and days, automatically outputting the correct string.

Step 2: Explain and Verify

Once you have an expression, paste it into our Cron Explainer. It will translate the cryptic syntax into human-readable English (e.g., "At minute 0, every 2nd hour, on Monday through Friday").

Step 3: Check Execution Times

Both tools run 100% locally in your browser. This means you can test schedules involving sensitive data or internal application logic without sending anything to a third-party server.


FAQ

What does */5 mean in cron?

It means every 5 units of that field. In the minute field, */5 means every 5 minutes starting from 0 (0, 5, 10, 15... 55).

What is the difference between 0 and 7 for Sunday in cron?

Both 0 and 7 represent Sunday. This is for compatibility with different cron implementations. Most modern systems accept both.

How do I run a cron job every 30 minutes?

Use the expression */30 * * * *. This ensures the job runs at minute 0 and minute 30 of every hour.

How do I test a cron expression without deploying it?

Use a local cron expression tester like the FmtDev Cron Explainer. It shows you exactly what the expression means in plain English.

Conclusion

Mastering cron syntax is essential for any developer managing servers or automated workflows. By understanding the 5 fields and the core logic of step values, ranges, and lists, you can automate almost any task with surgical precision.

👉 Generate your next Cron Expression with our Browser-Based Tool

Herramienta Asociada

¿Listo para usar la herramienta Constructor de Expresiones Cron en Línea? Todo el procesamiento es local.

Abrir Constructor de Expresiones Cron en Línea