mini-tools.dev icon

mini-tools.dev

May 22, 2025·8 min read

Cron Syntax: A Complete Guide with Examples

Cron is the standard Unix job scheduler. The expressions it uses look cryptic — 0 3 * * 1-5 — but they follow a simple, consistent pattern. Once you learn the five fields and four special characters, you can write any schedule from memory.

The five fields

A standard cron expression has five space-separated fields:

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

Some implementations (AWS EventBridge, Quartz Scheduler, Spring) use a 6-field format that prepends a seconds field, or append a year field. Standard Unix/Linux cron uses exactly 5 fields.

Special characters

  • * (asterisk) — "every value." * * * * * means every minute of every hour of every day.
  • , (comma) — list separator. 0,15,30,45 in the minute field means "at :00, :15, :30, and :45."
  • - (hyphen) — range. 1-5 in the day-of-week field means Monday through Friday.
  • / (slash) — step. */15 in the minute field means "every 15 minutes." 0/2 means "every even minute."

20 real-world examples

# Every minute
* * * * *

# Every 5 minutes
*/5 * * * *

# Every 15 minutes
*/15 * * * *

# Every hour (at :00)
0 * * * *

# Every hour at :30
30 * * * *

# Every day at midnight
0 0 * * *

# Every day at 3:00 AM
0 3 * * *

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

# Every weekday (Mon-Fri) at 9:00 AM
0 9 * * 1-5

# Every weekday at 9 AM and 5 PM
0 9,17 * * 1-5

# Every Monday at 8:00 AM
0 8 * * 1

# Every Sunday at midnight
0 0 * * 0

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

# Last business day of month (not directly supported in standard cron)
# Use 28th as a safe approximation for monthly reports
0 0 28 * *

# Every January 1st at midnight (New Year cleanup)
0 0 1 1 *

# Every quarter (Jan, Apr, Jul, Oct 1st at midnight)
0 0 1 1,4,7,10 *

# Every 6 hours
0 */6 * * *

# Twice a day (noon and midnight)
0 0,12 * * *

# Every 30 minutes during business hours (9 AM–5 PM, weekdays)
*/30 9-17 * * 1-5

# Every night at 2:30 AM for a database backup
30 2 * * *

Common mistakes

Day-of-month and day-of-week interact unexpectedly

When you specify both a day-of-month and a day-of-week (neither is *), most cron implementations use OR logic, not AND. So 0 9 1 * 1 means "at 9 AM on the 1st of every month or every Monday" — not "the first Monday of every month." To get the first Monday of each month, you need a workaround using a script that checks the date.

0 and 7 both mean Sunday

Day 0 and day 7 are both treated as Sunday in most Unix cron implementations. Use 0 for consistency; some tools only accept 0–6.

Timezone awareness

Standard cron runs in the server's local timezone, which is often UTC on cloud infrastructure. A job scheduled for 0 9 * * * on a UTC server fires at 9 AM UTC — which is 1 AM PST or 5 AM EST. Always specify timezones explicitly in documentation, and consider using a scheduler that supports timezone-aware expressions (like AWS EventBridge or GitHub Actions' schedule trigger, which runs in UTC).

Minute-level granularity is the minimum

Standard cron cannot schedule jobs more frequently than once per minute. If you need sub-minute scheduling, you either need multiple cron entries (at most 1-per-minute) or a different scheduler entirely (a job queue, a daemon with a sleep loop, or a cloud scheduler like AWS Step Functions).

Testing before you deploy

Paste your expression into a cron descriptor tool to verify it says what you think it says before you deploy it. A silent misconfiguration — a backup job that never runs, a report that fires at 3 AM instead of 3 PM — can take days to notice.

Related Tool

Cron Job Descriptor
Translate any cron expression into plain English instantly