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.
| Tier | Operator |
| JTBD | ”Stop pasting cron from Stack Overflow and never know what it means.” |
| Personas | All product users |
| Prerequisites | L1 |
| Time | 12 minutes |
| Bloom verb | Write (Apply) and Verify (Evaluate) |
1. Concept
Cron expressions look intimidating until you learn the syntax. The syntax is small: five fields, simple operators, a few conventions. Once internalized, cron becomes a second-nature notation.
The five fields
┌───────── minute (0-59) │ ┌───────── hour (0-23) │ │ ┌───────── day of month (1-31) │ │ │ ┌───────── month (1-12) │ │ │ │ ┌───────── day of week (0-6, Sunday = 0) │ │ │ │ │ * * * * *A field is either an exact number (5), a list (1,3,5), a range (1-5), a step (*/15), or wildcard (*).
The eight crons you’ll use 95% of the time
EXPRESSION HUMAN READABLE USE─────────────────────────────────────────────────────────────────────0 8 * * 1-5 every weekday at 8 AM morning start0 20 * * 1-5 every weekday at 8 PM evening stop0 9 * * 1-5 every weekday at 9 AM later morning0 0 * * 0,6 midnight Saturday + Sunday weekend stop0 0 * * 6 midnight Saturday Friday-night stop30 8 * * 1-5 every weekday at 8:30 AM half-hour grain0 */4 * * * every 4 hours, every day periodic ops0 22 * * 5 Friday at 10 PM weekend prepInternalize these and you can adapt them for almost any business-hour scenario.
The day-of-week field gotcha
Day of week uses 0 for Sunday in standard cron. Some tools use 7 for Sunday too (both work). The 1-5 notation means “Monday through Friday”: standard weekdays.
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:
Lfor “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:
"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:
0 8 * * 1-5 start at 8 AM0 18 * * 1-5 stop at 6 PMAggressive cost saver (10-hour weekday window + weekend off):
0 8 * * 1-5 start at 8 AM weekdays0 19 * * 1-5 stop at 7 PM weekdays0 0 * * 0,6 stop at midnight weekends (catches any drift)Asia + EU + Americas overlap (24-hour engineering coverage):
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):
0 12 * * * start (or scale up) at noon every day0 18 * * * stop (or scale down) at 6 PMAvoiding 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:
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 includeweekday business-hour stops, so dev stays running Monday-Fridayduring 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):
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. Every weekday (Mon-Fri) at 8:00 AM in the schedule’s IANA timezone
C. The first five days of the month at 8:00 AM
D. Five times at 8:00 AM
Show answer
Correct: B. 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 at 8 PM weekdays and never restart automatically (unless restarted manually or by another schedule)
B. Resources start themselves at midnight
C. The schedule is invalid
D. Resources stop continuously
Show answer
Correct: A. 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 minute 30 of hour 17 on days 1 through 5”
C. “the 30th of every month at 5 PM”
D. “every 30 minutes 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
1. 30 9 * * 1-52. 0 19 * * 1-53. 0 0 * * 0,64. */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"Related lessons
Glossary terms touched
Cron expression · Cronstrue · Day-of-week field · DST handling