OneKitTools logoOneKitTools
developer4 min read

"Cron Expressions Explained: From Basics to Advanced Schedules"

What is a cron expression? Learn the syntax, fields, and special characters — with real-world examples for common schedules like "every day at midnight" or "every Monday at 9am".

OneKitTools TeamApril 14, 2026

What Is a Cron Expression?

Cron is a time-based job scheduler built into Unix/Linux systems. A cron expression is the syntax that tells cron when to run a task.

You've seen them: 0 0 * * *. That means "at midnight, every day." But once you move past the basics, cron syntax gets tricky fast — there are 5 fields, optional seconds, platform differences, and special characters that most people copy-paste without understanding.

This guide makes it make sense.

The 5 (or 6) Fields

Standard cron uses 5 fields separated by spaces:

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

Some systems (AWS EventBridge, Spring, Quartz) add a seconds field at the start, making it 6 fields. Check your platform.

Special Characters

CharacterMeaningExample
*Every value* * * * * = every minute
,Multiple values0 9,17 * * * = 9am and 5pm
-Range0 9-17 * * * = every hour from 9am to 5pm
/Step*/15 * * * * = every 15 minutes
LLast0 0 L * * = last day of the month (Quartz only)
?No value0 0 ? * MON = Mondays, any day of month (Quartz)

Common Cron Expressions

Every minute

* * * * *

Every 5 minutes

*/5 * * * *

Every hour, on the hour

0 * * * *

Every day at midnight

0 0 * * *

Every day at 9am

0 9 * * *

Every Monday at 9am

0 9 * * 1

Every weekday (Mon–Fri) at 8am

0 8 * * 1-5

Every weekend at noon

0 12 * * 0,6

First day of every month at midnight

0 0 1 * *

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

0 0 1 1,4,7,10 *

Every 30 minutes between 9am and 5pm on weekdays

*/30 9-17 * * 1-5

The Traps

"Every 2 hours" is 0 */2 * * *, not */2 * * * *

*/2 * * * * means every 2 minutes. The step applies to the field it's in.

Sunday is both 0 and 7

In standard cron, 0 and 7 both mean Sunday. Avoid ambiguity — use 0 consistently.

Day-of-month AND day-of-week are OR, not AND

0 0 1 * 1 runs on the 1st of every month AND every Monday — not just Mondays that fall on the 1st. If you want "first Monday of the month," that's more complex (requires scripting logic outside cron itself).

Timezones

Cron runs in the server's local timezone unless configured otherwise. A job at 0 9 * * * on a UTC server runs at 9am UTC — which might be 2am or 11pm in your timezone.

Always check:

timedatectl   # shows current timezone on Linux

Named Shortcuts (Non-standard but widely supported)

ShortcutEquivalentMeaning
@yearly0 0 1 1 *Once a year
@monthly0 0 1 * *Once a month
@weekly0 0 * * 0Once a week (Sunday)
@daily0 0 * * *Once a day (midnight)
@hourly0 * * * *Once an hour
@rebootOn system startup

Generate and Validate Cron Expressions

Cron Generator lets you build expressions visually — pick the schedule in plain English, get the cron expression. No more guessing whether 0 9 * * 1-5 is correct.

It also works in reverse: paste any cron expression and get a plain-English explanation of when it runs.

Quick Reference Card

# ┌──── minute 0-59 # │ ┌─── hour 0-23 # │ │ ┌── day 1-31 # │ │ │ ┌─ month 1-12 # │ │ │ │ ┌ weekday 0-7 (0=Sun) # │ │ │ │ │ * * * * * every minute 0 * * * * every hour 0 0 * * * every day at midnight 0 9 * * 1 every Monday at 9am */15 * * * * every 15 minutes 0 0 1 * * first day of every month
Share