Skip to main content
Your progress
0 of 6 lessons complete0%
T1 / M1.3 / L2 OF 6 / Operator TIER / 12 min

Cron expressions without tears

Outcome

By the end of this lesson, you will be able to write cron expressions for common business-hour scenarios and verify them using the human-readable preview.


TierOperator
JTBD”Stop pasting cron from Stack Overflow and never know what it means.”
PersonasAll product users
PrerequisitesL1
Time12 minutes
Bloom verbWrite (Apply) and Verify (Evaluate)

1. Concept

A cron expression looks like somebody sat on a keyboard. It is not, and there is not much to it: five numbers in a fixed order, a handful of symbols, and two conventions worth knowing.

Half an hour with this page and you will read them without thinking about it.

The five fields

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

Each field takes one of five things: an exact number (5), a list (1,3,5), a range (1-5), a step meaning “every n” (*/15 is every fifteen), or *, meaning every value.

The eight crons you’ll use 95% of the time

Terminal window
EXPRESSION HUMAN READABLE USE
─────────────────────────────────────────────────────────────────────
0 8 * * 1-5 every weekday at 8 AM morning start
0 20 * * 1-5 every weekday at 8 PM evening stop
0 9 * * 1-5 every weekday at 9 AM later morning
0 0 * * 0,6 midnight Saturday + Sunday weekend stop
0 0 * * 6 midnight Saturday Friday-night stop
30 8 * * 1-5 every weekday at 8:30 AM half-hour grain
0 */4 * * * every 4 hours, every day periodic ops
0 22 * * 5 Friday at 10 PM weekend prep

Learn these eight and you can build almost any working-hours schedule by changing a number.

The day-of-week field gotcha

The week starts on Sunday, and Sunday is 0. Some tools also accept 7 for Sunday, and both work here. So 1-5 is Monday to Friday, the ordinary working week.

0,6 means “Sunday and Saturday”, the weekend. Some teams write 6,0, same thing, parsed identically.

What ZopNight does NOT support

Cron has some advanced features that are not supported in ZopNight schedules:

  • L for “last day of month”: not supported, use specific day
  • # for “nth occurrence” (e.g., 5#2 = second Friday): not supported
  • ? placeholder: not supported (use *)
  • Seconds field: not supported (5 fields only, no seconds)
  • Year field: not supported

These omissions keep the syntax simple. For complex scenarios, use multiple crons in one schedule rather than one elaborate cron.

Cron with timezone

The cron is interpreted in the schedule’s IANA timezone (from L1). 0 8 * * 1-5 in America/New_York means “8 AM Eastern”: which becomes 8 AM EST during winter and 8 AM EDT during summer. ZopNight handles the DST transition; the cron expression stays the same year-round.

The human-readable preview

The create dialog renders every cron in plain English:

Terminal window
"0 8 * * 1-5" → "every weekday at 8:00 AM"
"30 17 * * 1-5" → "every weekday at 5:30 PM"
"0 0 * * 0,6" → "every Saturday and Sunday at 12:00 AM"
"0 */4 * * *" → "every 4 hours"
"*/15 9-17 * * 1-5" → "every 15 minutes, between 9:00 AM and 5:00 PM,
on every weekday"

If the preview reads what you intended, the cron is correct. If the preview disagrees with your intent, the cron is wrong.

The preview is generated by the cronstrue library (the industry standard for cron-to-prose conversion). If you have any doubt about a cron’s behavior, trust the preview.

Common writing patterns

Business hours, weekdays only:

Terminal window
0 8 * * 1-5 start at 8 AM
0 18 * * 1-5 stop at 6 PM

Aggressive cost saver (10-hour weekday window + weekend off):

Terminal window
0 8 * * 1-5 start at 8 AM weekdays
0 19 * * 1-5 stop at 7 PM weekdays
0 0 * * 0,6 stop at midnight weekends (catches any drift)

Asia + EU + Americas overlap (24-hour engineering coverage):

Terminal window
0 7 * * 1-5 start at 7 AM (Asia / EU / Americas: three separate schedules
in three timezones)
0 23 * * 1-5 stop at 11 PM (each in local timezone)

Peak hours scaling (afternoon-only):

Terminal window
0 12 * * * start (or scale up) at noon every day
0 18 * * * stop (or scale down) at 6 PM

Avoiding common cron mistakes

Three mistakes worth flagging:

Mistake 1: AM/PM confusion. 0 8 is 8 AM. 0 20 is 8 PM (24-hour notation). Beginners sometimes write 0 8 intending PM. The human-readable preview catches this: verify “8:00 AM” or “8:00 PM” matches your intent.

Mistake 2: Day-of-month vs. day-of-week. 0 8 1-5 * * (day-of-month 1-5) is not the same as 0 8 * * 1-5 (day-of-week 1-5). The first fires on the first five days of every month; the second fires on weekdays. The asterisk positions matter.

Mistake 3: Forgetting weekend behavior. A schedule with 0 20 * * 1-5 (stop Friday at 8 PM) but no 0 8 * * 1-5 start does nothing on weekends. If resources were already off, they stay off. If they were on, they stay on. The intent is usually to ensure weekend-off via an explicit 0 0 * * 0,6 stop cron.


2. Demo

A real customer’s first schedule, walked through:

Terminal window
INTENT: "Stop dev environments at 8 PM Friday, start at 9 AM Monday.
Cost-aware but engineer-friendly."
CRON CONSTRUCTION:
Cron #1 Stop at 8 PM Friday "0 20 * * 5" action: Stop
Cron #2 Start at 9 AM Monday "0 9 * * 1" action: Start
HUMAN READABLE PREVIEW:
"every Friday at 8:00 PM"
"every Monday at 9:00 AM"
This intent reduces to two crons. Note: the schedule does NOT include
weekday business-hour stops, so dev stays running Monday-Friday
during the day. The intent is weekend-only economy.
If the intent were "weekdays 8am-8pm only, weekends off":
Cron #1 "0 8 * * 1-5" action: Start
Cron #2 "0 20 * * 1-5" action: Stop
Cron #3 "0 0 * * 0,6" action: Stop (weekend belt-and-suspenders)
Three crons together produce an explicit, gap-free schedule.

3. Hands-on (8 min)

Write each of these crons. Verify with the ZopNight preview (or any cron-to-prose tool):

Terminal window
1. Weekdays start at 9:30 AM: ___________
2. Weekdays stop at 7 PM: ___________
3. Saturday and Sunday stop at midnight: ___________
4. Every 15 minutes during weekday business hours: ___________
5. Stop at 10 PM every day: ___________
6. Start on the 1st and 15th of every month at 9 AM: ___________
(use day-of-month, not day-of-week)
7. Stop every 4 hours starting at midnight: ___________
8. Start every weekday at 8 AM in Asia/Kolkata
(the cron itself stays the same; the timezone field handles the locality)
Cron: ___________ Timezone: ___________

ANSWERS in the footer of this lesson: try first.


4. Knowledge check

Q1

The cron 0 8 * * 1-5 fires:

A. Every day at 8:00 AM
B. The first five days of every calendar month, at exactly 8:00 AM
C. Five times at 8:00 AM
D. Every weekday (Mon-Fri) at 8:00 AM in the schedule’s IANA timezone

Show answer

Correct: D. Day-of-week 1-5 = Monday through Friday. The schedule’s timezone handles DST transitions automatically.

Q2

A schedule has cron 0 20 * * 1-5 (stop at 8 PM weekdays) but no start cron. The likely outcome:

A. Resources stop continuously
B. Resources stop at 8 PM weekdays and never restart automatically (unless restarted manually or by another schedule)
C. The resources start themselves again at midnight, since the stop cron has no matching start cron set
D. The schedule is invalid

Show answer

Correct: B. Cron fires only the stop action. No start cron means no automatic start. The resource stays stopped until manually restarted, an override fires, or another schedule starts it.

Q3

The human-readable preview for 30 17 * * 1-5 reads:

A. “every weekday at 5:30 PM”
B. “every 30 minutes at 5 PM”
C. “every minute 30 of hour 17 on days 1 through 5”
D. “the 30th of every month at 5 PM”

Show answer

Correct: A. Cronstrue translates cron to plain English. 30 17 * * 1-5 = minute 30, hour 17, every weekday → “every weekday at 5:30 PM”.


5. Apply

Cron expressions are the universal scheduling notation:

  • Schedule create dialog: the form validates cron syntax and shows the human-readable preview as you type
  • crontab.guru: popular community reference for cron syntax
  • ZopNight inline help: every cron field carries tooltip help

For complex scheduling patterns, use multiple simple crons in one schedule rather than one elaborate cron. The latter is harder to read, harder to debug, and not actually more efficient.


Hands-on answers

Terminal window
1. 30 9 * * 1-5
2. 0 19 * * 1-5
3. 0 0 * * 0,6
4. */15 8-19 * * 1-5 (or 9-17 depending on intent)
5. 0 22 * * *
6. 0 9 1,15 * *
7. 0 */4 * * *
8. Cron: "0 8 * * 1-5" Timezone: "Asia/Kolkata"

Glossary terms touched

Cron expression · Cronstrue · Day-of-week field · DST handling


Start with the bill.

Foundations takes about five hours. The first lesson is nine minutes.

Open curriculum. No login. No paywall. 290 lessons across 7 courses, three publicly verifiable credentials. Read it on the train, take the exam on a Saturday, list the credential on your résumé Monday.

5h median time to finish Foundations
0 logins, paywalls, or marketing forms
open curriculum, public credential verifier
Multi-cloud automation· Production-ready in 30 min· SOC 2 · ISO 27001· 20–60% off the bill, first month· 4 platforms · 1 console· Multi-cloud automation· Production-ready in 30 min· SOC 2 · ISO 27001· 20–60% off the bill, first month· 4 platforms · 1 console·