Devkitrdevkitr
Dev Utilities

Cron Expressions Explained — Syntax, Examples & Common Schedules

2025-11-288 min read

Cron expressions define schedules for automated tasks. Originally from Unix cron, they're now used everywhere — Kubernetes CronJobs, GitHub Actions, AWS EventBridge, CI/CD pipelines, and task schedulers in virtually every programming language.


Anatomy of a Cron Expression


A standard cron expression has 5 fields:


┌───────────── minute (0-59)

│ ┌───────────── hour (0-23)

│ │ ┌───────────── day of month (1-31)

│ │ │ ┌───────────── month (1-12)

│ │ │ │ ┌───────────── day of week (0-6, 0=Sunday)

│ │ │ │ │

* * * * *


Some systems add a 6th field for seconds at the beginning.


Special Characters


  • * — any value (wildcard)
  • , — list separator: 1,15 means "1 and 15"
  • - — range: 1-5 means "1 through 5"
  • / — step: */5 means "every 5"
  • ? — no specific value (used in some systems for day-of-month or day-of-week)
  • L — last (e.g., L in day-of-month = last day of month)
  • W — weekday nearest to the given day
  • # — nth occurrence (e.g., 5#2 = second Friday)

  • Common Schedule Examples


    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 at 6 PM

    0 18 * * 1-5


    First day of every month at noon

    0 12 1 * *


    Every 15 minutes during business hours (9-5, Mon-Fri)

    */15 9-17 * * 1-5


    Every quarter (Jan 1, Apr 1, Jul 1, Oct 1) at midnight

    0 0 1 1,4,7,10 *


    Twice a day (8 AM and 8 PM)

    0 8,20 * * *


    Platform-Specific Shorthand


    Some platforms support predefined schedules:


  • @yearly or @annually0 0 1 1 *
  • @monthly0 0 1 * *
  • @weekly0 0 * * 0
  • @daily or @midnight0 0 * * *
  • @hourly0 * * * *

  • Common Mistakes


  • Confusing day-of-week numbering (0 = Sunday in standard cron, 1 = Monday in some systems)
  • Forgetting that both day-of-month AND day-of-week are checked (OR logic, not AND)
  • Setting */5 in the hour field thinking it runs every 5 minutes (it runs every 5 hours)
  • Not accounting for timezone differences on servers
  • Overlapping schedules when combining ranges and lists

  • Debugging Tips


  • Always verify your expression with a parser before deploying
  • Check the next 5-10 execution times to confirm the schedule is correct
  • Consider timezone — most cron engines use server local time or UTC
  • Start with verbose schedules and simplify once tested

  • Parse and validate your cron expressions with our Cron Expression Parser.


    Related Articles

    Back to Blog