Skip to content
← Blog

Cron Expression Syntax for Beginners

6 min readGuides

Cron is the standard job scheduler on Unix and Linux systems. It runs commands on a schedule defined by a five-field expression. Whether you are scheduling database backups, log rotation, CI/CD pipelines, or Kubernetes CronJobs, understanding cron syntax is an essential skill.

This guide teaches the five-field format from scratch with practical examples you can use today.

The Five Fields

A cron expression has five fields separated by spaces:

┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6, Sun=0)
│ │ │ │ │
* * * * *

Each field accepts:

  • A specific value: 5
  • A wildcard (any value): *
  • A range: 1-5
  • A list: 1,3,5
  • A step: */15 (every 15th value)

Common Examples

ExpressionSchedule
* * * * *Every minute
0 * * * *Every hour (at minute 0)
0 0 * * *Daily at midnight
0 9 * * 1-5Weekdays at 9:00 AM
0 0 1 * *First of every month at midnight
*/15 * * * *Every 15 minutes
0 */6 * * *Every 6 hours
30 2 * * 0Sundays at 2:30 AM
0 9,17 * * *At 9:00 AM and 5:00 PM daily
0 0 * * 1Every Monday at midnight

Field Details

Minute (0-59)

0      → at the top of the hour
30     → at half past
*/5    → every 5 minutes (0, 5, 10, 15, ...)
5,35   → at minutes 5 and 35

Hour (0-23)

Uses 24-hour format. 0 is midnight, 12 is noon, 23 is 11 PM.

9      → 9:00 AM
*/2    → every 2 hours (0, 2, 4, 6, ...)
9-17   → every hour from 9 AM to 5 PM

Day of Month (1-31)

1      → first of the month
15     → fifteenth
1,15   → first and fifteenth

Not all months have 31 days. If you schedule day 31, the job skips months with fewer days.

Month (1-12)

1      → January
6      → June
1-3    → January through March
*/3    → every 3 months (Jan, Apr, Jul, Oct)

Day of Week (0-6)

0 and 7 both mean Sunday. 1 = Monday through 6 = Saturday.

0      → Sunday
1-5    → Monday through Friday (weekdays)
6,0    → weekends

Step Syntax (*/n)

The step syntax */n means "every nth value starting from the field minimum":

  • */15 in the minute field → 0, 15, 30, 45
  • */6 in the hour field → 0, 6, 12, 18
  • */2 in the day-of-week field → 0, 2, 4, 6

You can combine steps with ranges: 1-30/5 means every 5th value from 1 to 30 (1, 6, 11, 16, 21, 26).

Real-World Examples

Database backup every night at 2 AM

0 2 * * *

Log rotation every Sunday at 3:30 AM

30 3 * * 0

Health check every 5 minutes during business hours

*/5 9-17 * * 1-5

Monthly report on the 1st at 8 AM

0 8 1 * *

Deploy to staging every weekday at 6 PM

0 18 * * 1-5

Common Mistakes

  1. Confusing day-of-month and day-of-week — if both are set to non-wildcard values, most cron implementations run when either matches (OR logic), not when both match (AND logic). This catches many people.
  2. Timezone confusion — system cron uses the server's timezone. Kubernetes CronJobs default to UTC. Always specify which timezone your schedule targets.
  3. Running at boot, not by schedule@reboot is a special string, not a cron expression. It runs once when the cron daemon starts.
  4. Forgetting that */n starts at 0*/10 in the hour field runs at 0:00, 10:00, 20:00 — not at the current time plus 10 hours.
  5. Output accumulation — cron emails stdout and stderr to the user. Redirect output to avoid filling the mailbox: 0 * * * * /path/to/script > /dev/null 2>&1

Special Strings

Most cron implementations support these shortcuts:

StringEquivalent
@yearly0 0 1 1 *
@monthly0 0 1 * *
@weekly0 0 * * 0
@daily0 0 * * *
@hourly0 * * * *
@rebootRun once at startup

Try It

Build and validate cron expressions interactively with StackCache Cron Schedule Builder. It shows the next execution times and translates expressions into plain English — all in your browser with no account needed.

Try it yourself

Open the tool mentioned in this guide — it runs locally in your browser, no account needed.

Open tool