cron.express

The Complete Guide to Cron Expressions

Everything you need to know about cron expressions, from basics to advanced scheduling across different platforms.

1. What is Cron?

Cron is a time-based job scheduler in Unix-like operating systems. Users can schedule jobs (commands or scripts) to run periodically at fixed times, dates, or intervals. The name "cron" comes from the Greek word "chronos" meaning time.

A cron expression is a string that defines when a scheduled task should run. It's used not just in Unix systems, but also in many modern platforms like Kubernetes, cloud services (AWS, Azure, GCP), CI/CD pipelines (GitHub Actions, GitLab CI), and application frameworks (Spring, Quartz).

2. Cron Expression Fields

A standard Unix cron expression consists of 5 fields separated by spaces:

FieldAllowed ValuesDescription
Minute0-59Minute of the hour
Hour0-23Hour of the day (24-hour format)
Day of Month1-31Day of the month
Month1-12 or JAN-DECMonth of the year
Day of Week0-6 or SUN-SATDay of the week (0 = Sunday)
┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6)
│ │ │ │ │
* * * * *

3. Special Characters

Cron expressions support several special characters to create complex schedules:

* (asterisk) — Every value.

Example: * * * * * runs every minute.

, (comma) — List of values.

Example: 0,15,30,45 * * * * runs at minutes 0, 15, 30, 45.

- (hyphen) — Range of values.

Example: 0 9-17 * * * runs every hour from 9 AM to 5 PM.

/ (slash) — Step values.

Example: */5 * * * * runs every 5 minutes.

? (question mark) — No specific value (Quartz, AWS).

Used in day-of-month or day-of-week when the other field is specified.

4. Common Examples

* * * * *

Every minute

*/5 * * * *

Every 5 minutes

0 * * * *

Every hour at minute 0

0 0 * * *

Every day at midnight

0 9 * * 1-5

Every weekday at 9 AM

0 0 1 * *

First day of every month at midnight

0 0 * * 0

Every Sunday at midnight

5. Cron Flavors Compared

Different platforms have variations on the standard cron syntax. Here's how they compare:

PlatformFieldsNotes
Unix/Linux5Standard format: min hour dom mon dow
Quartz6-7Adds seconds (and optional year). Uses ? character.
Spring6Seconds minute hour dom mon dow
GitHub Actions5Standard Unix format, UTC timezone
AWS EventBridge6Wrapped in cron(). Uses ?.
Azure Functions6NCRONTAB format with seconds

Quartz Example

0 0 12 * * ?    # Every day at 12:00 PM

The first 0 is seconds, ? means no specific day-of-week.

AWS EventBridge Example

cron(0 12 * * ? *)    # Every day at 12:00 PM UTC

Note the cron() wrapper and 6 fields with year.

Spring Example

0 0 */2 * * *    # Every 2 hours

First field is seconds (set to 0).

GitHub Actions Example

0 9 * * 1-5    # Weekdays at 9 AM UTC

Standard 5-field format. Remember: GitHub Actions always runs in UTC.

Azure Functions (NCRONTAB) Example

0 30 9 * * 1-5    # Weekdays at 9:30 AM

6-field format with seconds first. Supports timezone configuration in host.json.

6. Common Pitfalls

Timezone Confusion

GitHub Actions and many cloud services run in UTC. Always verify your cron's timezone and convert from your local time.

Day-of-Month vs Day-of-Week

In Quartz/AWS, specifying both day-of-month and day-of-week can cause unexpected behavior. Use ? for the field you don't need.

Forgetting Seconds

Quartz, Spring, and Azure Functions require 6 fields. Missing the seconds field will cause parse errors.

Invalid Day-Month Combinations

Setting 0 0 31 2 * (Feb 31) will never run. Some systems silently skip; others error.

Ready to build your cron expression?

Use our visual builder to create and validate cron expressions instantly.

Try the Cron Builder