Cron Expression Examples: A Complete Guide for Developers

Cron is the standard Unix scheduler — but its five-field syntax trips up developers every time they need to schedule something non-trivial. This guide walks through every field, every special character, and the common patterns you'll actually reach for.

What Is a Cron Expression?

A cron expression is a string of five fields separated by spaces that defines a schedule for recurring jobs. Each field represents a unit of time:

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

The cron daemon reads the crontab file and wakes up every minute to check which jobs match the current time. If all five fields match, the command runs.

Field Breakdown

FieldPositionRangeNotes
Minute1st0–59
Hour2nd0–2324-hour clock
Day of month3rd1–31Not all months have 31 days
Month4th1–12Also accepts JAN–DEC
Day of week5th0–60 = Sunday; also accepts SUN–SAT

Special Characters

* — Any value

Matches every value in the field. * * * * * runs every minute of every hour of every day.

/ — Step values

Defines an interval. */15 in the minute field means "every 15 minutes". 2/3 means "starting at 2, every 3 steps" — so 2, 5, 8, 11, ...

- — Ranges

Defines a continuous range. 9-17 in the hour field means hours 9 through 17 inclusive. 1-5 in the day-of-week field means Monday through Friday.

, — Lists

Specifies multiple individual values. 0,15,30,45 in the minute field runs at minutes 0, 15, 30, and 45. MON,WED,FRI in the day-of-week field runs on those three days.

Common Examples

ExpressionDescription
* * * * *Every minute
0 * * * *Every hour, on the hour
0 0 * * *Every day at midnight
0 9 * * 1-59:00 AM on weekdays (Mon–Fri)
*/15 * * * *Every 15 minutes
0 0,12 * * *Midnight and noon every day
0 9 1 * *9:00 AM on the 1st of every month
30 6 * * 16:30 AM every Monday
0 0 1 1 *Midnight on January 1st (yearly)
0 */4 * * *Every 4 hours
5 4 * * sun4:05 AM every Sunday
0 22 * * 1-510:00 PM on weekdays

Extended Cron: @shortcuts

Most modern cron implementations support shorthand strings that replace the five-field syntax:

ShorthandEquivalentMeaning
@reboot(none)Once at startup
@yearly / @annually0 0 1 1 *Once a year, Jan 1
@monthly0 0 1 * *Once a month, 1st day
@weekly0 0 * * 0Once a week, Sunday midnight
@daily / @midnight0 0 * * *Once a day, midnight
@hourly0 * * * *Once an hour, top of hour

Validation Tips

  • Always test before deploying. An expression like 0 0 31 * * only runs on months that have a 31st day — February, April, June, September, and November will silently skip it.
  • Day-of-month and day-of-week interact oddly. If both are set to non-* values, most cron implementations run the job if either condition matches (OR logic, not AND). Use * in one field when you only mean to restrict the other.
  • Watch your timezone. Cron runs in the server's system timezone. A job scheduled for 0 9 * * * fires at 9 AM server time, not your local time.
  • Use absolute paths. Cron runs with a stripped-down environment. Replace python3 script.py with /usr/bin/python3 /home/user/script.py.

Build and Validate Cron Expressions Online

If you want to visually build a cron expression and see a plain-English description, the Cron Builder on DevEssentials generates valid cron syntax from a GUI and explains any expression you paste in. No login, 100% client-side.


Need to build a cron expression? Use the visual Cron Builder →

Frequently Asked Questions

What does */5 mean in a cron expression?

The */5 syntax means 'every 5 units'. In the minute field, */5 means every 5 minutes (0, 5, 10, 15, ..., 55). In the hour field, */5 means every 5 hours (0, 5, 10, 15, 20). The * means 'all values' and /5 is the step — so together it reads 'starting from the first value, every 5 steps'.

What is the difference between 0 * * * * and * * * * *?

0 * * * * runs once per hour, at minute 0 (top of the hour). * * * * * runs every single minute. The first field is always minutes — setting it to 0 means 'only when the minute is exactly 0', while * means 'every minute'.

How do I run a cron job on weekdays only?

Use 1-5 in the day-of-week field (the 5th field). For example, 0 9 * * 1-5 runs at 9:00 AM Monday through Friday. Day values are: 0 = Sunday, 1 = Monday, ..., 6 = Saturday. Some systems also accept 7 for Sunday.

What does @reboot mean in cron?

@reboot is a non-standard cron extension supported by most modern cron implementations (Vixie cron, cronie, fcron). It runs the job once when the cron daemon starts, which is typically at system boot. It's equivalent to running a command in a startup script. Other shortcuts: @yearly (0 0 1 1 *), @monthly (0 0 1 * *), @weekly (0 0 * * 0), @daily (0 0 * * *), @hourly (0 * * * *).

Why is my cron job not running at the expected time?

The most common cause is timezone confusion. Cron runs in the system timezone of the server, which may differ from your local timezone or UTC. Check the server timezone with timedatectl or date +%Z.

Other common issues: the command works in an interactive shell but fails in cron because cron has a minimal environment (no PATH, no env vars). Always use absolute paths in cron commands (e.g. /usr/bin/python3 instead of python3). Also check /var/log/cron or /var/log/syslog for error output.