Blog
Custom Print on Demand Apparel — Free Storefront for Your Business
Wild & Free Tools

How to Write Cron Expressions — A Beginner's Step-by-Step Guide

Last updated: April 20267 min readDeveloper Tools

Cron expressions tell computers when to run tasks automatically. If you have never written one before, the five-field format looks intimidating — but each field answers one simple question, and you can learn the entire syntax in under 10 minutes.

The Five Fields

Every cron expression is five values separated by spaces. Read them left to right:

PositionFieldRangeQuestion It Answers
1stMinute0-59At which minute?
2ndHour0-23At which hour? (24-hour clock)
3rdDay of Month1-31On which day of the month?
4thMonth1-12In which month?
5thDay of Week0-6 (0=Sunday)On which day of the week?

That is the entire structure. Five questions, five answers. When all five conditions match the current time, your task runs.

Step 1 — Start With a Simple Schedule

Build cron expressions by starting simple and adding specificity:

Notice the pattern: specific values narrow the schedule, asterisks keep it open.

Step 2 — Learn the Four Special Characters

CharacterMeaningExampleResult
*Every value* * * * *Every minute
/Step (every Nth)*/5 * * * *Every 5 minutes
-Range0 9-17 * * *Every hour from 9 AM to 5 PM
,List0 9 * * 1,3,59 AM on Mon, Wed, Fri

Step 3 — Build Common Schedules

Walk through these examples to see how the fields work together:

Every 5 minutes:

Every hour at the 30-minute mark:

Every weekday at 9 AM:

Twice a day (9 AM and 5 PM):

First of every month at midnight:

Every 15 minutes during business hours on weekdays:

Skip the manual writing — build cron expressions visually and see the schedule in plain English.

Open Cron Generator

Step 4 — Use the Generator to Verify

  1. Open the Cron Expression Generator
  2. Type or build your expression
  3. Read the human-readable description — it tells you exactly when the job will run
  4. Check the next execution times to confirm the schedule matches your intent
  5. Copy and paste into your crontab or scheduler config

This verification step catches the most common mistake: writing an expression that runs far more or less often than you intended.

Common Gotchas for Beginners

MistakeWhat You WroteWhat HappensCorrect Expression
Star in minute field* 9 * * *Runs every minute from 9:00 to 9:59 (60 times)0 9 * * *
Wrong day-of-week number0 9 * * 7Sunday on some systems, error on others0 9 * * 0 (Sunday)
Both day fields set0 9 15 * 1Runs on the 15th AND every Monday (OR logic)Use only one day field
Month names misspelled0 9 1 Janu *Error — use JAN or 10 9 1 1 * or 0 9 1 JAN *
24-hour time confusion0 9 * * * (expecting PM)Runs at 9 AM, not 9 PM0 21 * * * (9 PM = hour 21)
Forgetting leading zero9 * * * * vs 09Both work — cron ignores leading zerosEither format is fine

Day-of-Week Reference

NumberDayMnemonic
0SundayStart of week (Unix convention)
1Monday
2Tuesday
3Wednesday
4Thursday
5Friday
6Saturday

Some systems accept 7 for Sunday as well, but 0 is universal. When in doubt, use 0.

Practice Exercises

Try building these schedules yourself, then verify with the generator:

  1. Every 10 minutes — */10 * * * *
  2. Every day at 3:30 PM — 30 15 * * *
  3. Every Tuesday and Thursday at 8 AM — 0 8 * * 2,4
  4. Every first and fifteenth of the month at noon — 0 12 1,15 * *
  5. Every 6 hours starting at midnight — 0 */6 * * *

Developer Tools for Your Workflow

New to cron? The visual generator builds expressions for you. Just pick a frequency and copy.

Open Cron Generator
Launch Your Own Clothing Brand — No Inventory, No Risk