FmtDev
Idioma
Back to blog
March 18, 2026

Cron Job Syntax Explained: Every Symbol, Every Field (With Examples)

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. How to Build and Test Cron Expressions
  6. 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

| Field | Required | Allowed Values | Allowed Special Characters | | :--- | :--- | :--- | :--- | | Minute | Yes | 0-59 | * , - / | | Hour | Yes | 0-23 | * , - / | | Day of Month | Yes | 1-31 | * , - / | | Month | Yes | 1-12 (or JAN-DEC) | * , - / | | Day of Week | Yes | 0-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.

| Expression | Meaning | Typical Use Case | | :--- | :--- | :--- | | * * * * * | Every single minute | Monitoring, 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 * * 0 | Every Sunday at midnight | Weekly maintenance, system updates | | 0 0 1 * * | First day of every month | Monthly billing, invoice generation | | 0 9 * * 1-5 | 9:00 AM, Monday to Friday | Warm up caches before work hours | | */5 * * * * | Every 5 minutes | Small intervals, status checks | | 0 */2 * * * | Every 2 hours | Medium-frequency data ingestion | | 30 18 * * * | 6:30 PM every day | End-of-day data snapshot | | 0 1 1 1 * | Yearly (New Year's Day) | Annual security audits | | 0 22 * * 1-5 | 10:00 PM, Mon-Fri | Off-peak processing (Weekdays) | | 0 0 * * 6,0 | Midnight on Sat and Sun | Weekend-only database indexing | | */15 9-17 * * * | Every 15 min, during 9am-5pm | High-traffic sync during business hours | | 0 12 * * * | Every Noon | Middy synchronization | | 0 4 * * * | 4:00 AM every day | Low-traffic heavy task (e.g., reindexing) | | 0 1 * * 1 | 1:00 AM every Monday | Start of week data reset | | 0 0 1-7 * 1 | First Monday of the Month | Monthly payroll or meeting prep | | 0 0 15 * * | 15th of the Month | Mid-month performance review | | 45 23 * * * | 11:45 PM every day | Final daily record consolidation | | */30 * * * * | Every 30 minutes | Periodic 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.


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

Related Formatting Tool

Need to format your code right now? Use our secure tools.

Open JSON Formatter