Generators7 min read

Cron Expression Syntax: Complete Guide with Examples

Learn cron expression syntax field by field with practical examples. Covers standard 5-field cron, extended 6-field formats, special strings, and common patterns for scheduling jobs.

Try the free online tool mentioned in this guide:Cron Expression Builder

What is a cron expression?

A cron expression is a string of fields that defines a schedule for repeating tasks. The name comes from the Unix cron daemon, which reads a crontab file and executes commands at the specified times. Today cron syntax is used far beyond Unix: in Kubernetes CronJobs, AWS EventBridge rules, GitHub Actions workflows, task queues, and cloud functions.

The five standard fields

A standard cron expression has five space-separated fields:

text
┌───────────── minute (0–59)
│ ┌─────────────── hour (0–23)
│ │ ┌───────────────── day of month (1–31)
│ │ │ ┌─────────────────── month (1–12)
│ │ │ │ ┌───────────────────── day of week (0–7, 0 and 7 = Sunday)
│ │ │ │ │
* * * * *

Special characters

  • * — any value (wildcard)
  • , — value list: 1,15 means 1st and 15th
  • - — range: 9-17 means every hour from 9 to 17
  • / — step: */5 means every 5 units, 0/15 means every 15 units starting at 0
  • L — last (day-of-month or day-of-week) — supported in Quartz/Spring but not standard cron
  • ? — no specific value — used in day-of-month/day-of-week when the other is specified (Quartz/Spring)

Common cron expressions with explanations

Here are the most frequently used patterns:

bash
# Every minute
* * * * *

# Every 5 minutes
*/5 * * * *

# Every hour at minute 0
0 * * * *

# Every day at midnight
0 0 * * *

# Every day at 9:30 AM
30 9 * * *

# Every Monday at 8 AM
0 8 * * 1

# Every weekday (Mon–Fri) at 6 PM
0 18 * * 1-5

# First day of every month at midnight
0 0 1 * *

# Every 15 minutes
*/15 * * * *

# Twice a day: midnight and noon
0 0,12 * * *

# Every Sunday at 2 AM
0 2 * * 0

6-field cron (with seconds)

Many modern schedulers (Quartz, Spring, AWS EventBridge) add a seconds field as the first field, giving six total fields. The second field (0–59) precedes the standard five.

bash
# Quartz/Spring 6-field format (seconds first)
# ┌─────────────── second (0–59)
# │ ┌───────────── minute (0–59)
# │ │ ┌─────────── hour (0–23)
# │ │ │ ┌───────── day of month (1–31)
# │ │ │ │ ┌─────── month (1–12)
# │ │ │ │ │ ┌───── day of week (0–7)
# │ │ │ │ │ │
  0 */5 * * * *    # every 5 minutes exactly at second 0

Special @strings

Many cron implementations support named shortcuts:

bash
@yearly    # = 0 0 1 1 *   — once a year on Jan 1 at midnight
@monthly   # = 0 0 1 * *   — once a month on the 1st at midnight
@weekly    # = 0 0 * * 0   — once a week on Sunday at midnight
@daily     # = 0 0 * * *   — once a day at midnight
@hourly    # = 0 * * * *   — once an hour
@reboot    # — run once at startup (Linux cron only)

Validating cron expressions

Off-by-one errors and ambiguous day-of-week numbering are the most common cron mistakes. Some systems use 0 for Sunday, some use 7, and some accept both. Use an online cron builder to preview the next 10 scheduled runs before deploying. MyDevTools Cron Builder shows a human-readable description ("At 9:30 AM, every Monday") and lists the next occurrences so you can confirm the schedule is exactly what you intend.

Frequently asked questions

What is the difference between */5 and 0/5 in a cron expression?

*/5 means every 5 units starting from the minimum (0). 0/5 explicitly starts at 0. In practice they produce the same result for most fields, but 0/5 is more explicit.

How do I run a cron job every 30 seconds?

Standard 5-field cron has minute precision. To run every 30 seconds, use a 6-field cron scheduler (like Quartz) or schedule two jobs in standard cron: * * * * * cmd && sleep 30 && cmd.

Does cron use UTC or local time?

Standard Unix cron uses the system's local timezone. Cloud schedulers (AWS EventBridge, GCP Cloud Scheduler) default to UTC. Always verify the timezone setting in your scheduler to avoid unexpected 1-hour shifts during daylight saving changes.

Why does my cron expression work in one tool but not another?

Different schedulers support different field counts (5 vs 6), different special characters (L, W, #, ?), and different day-of-week numbering. Always check the documentation for the specific scheduler you are using.

Try Cron Expression Builder for free

Build 5-field cron jobs with presets and quick picks, edit raw expressions, read plain-English schedules, and preview next run times. No install, no account required to try it.