Cron Expressions: A Practical Guide
One wrong asterisk and backups run in the wrong hour. Learn the five fields, then set TZ on the host. Do not mix Quartz seven-field lines with Linux crontab.
What is a cron expression?
A typical Linux crontab line has five fields: minute, hour, day of month, month, day of week. Values may be numbers, * (every), lists, ranges, and */n steps.
0 0 * * * is minute 0, hour 0, every day—midnight on the machine’s clock. There is no timezone in the expression. A UTC container will not honor “3am in Beijing” unless TZ is set.
Six- and seven-field forms (seconds, year) show up in Quartz and some Java schedulers. They are not interchangeable with Linux. Our cron generator targets five-field crontab: build or explain a line.
Why cron?
Backups, reports, cache wipes, and cert renewals should fire on a clock without a forever-loop process. Cron still will not make the job idempotent; you must.
Reading someone else’s line is harder than writing one. */5 9-18 * * 1-5 needs a field-by-field reading. The generator’s explanation exists to cut that ambiguity.
Cron does not watch exit codes or DST surprises. If the wall clock looks wrong, convert “now” with the timestamp tool.
How to write one
Once a day: 0 3 * * * at 03:00. Mondays at 09:30: 30 9 * * 1 (Sunday is often 0 or 7—check your cron). First of the month: 0 0 1 * *.
Steps: */15 * * * *. Ranges: 0 9-17 * * *. Lists: 0 0,12 * * *. Day-of-month plus day-of-week together is implementation-defined (OR vs AND). Read the man page.
Compose in the generator or paste an existing line. Confirm TZ in crontab -l and in the platform UI. Kubernetes schedule is five fields; zone is a separate field when the API supports it.
Timezones, nicknames, and non-goals
@daily aliases exist on some crons and not on busybox. Quartz tokens like L, W, ? will fail in vixie cron.
DST may skip or double a run. Critical jobs should be written in UTC or re-checked inside the script.
Cron is not millisecond scheduling and does not take Unix timestamps as fields. HTTP/cURL helpers live on the DevOps hub; time tools on the time hub.
Related tools
FAQ
What does 0 0 * * * mean?
Midnight every day in the timezone of the host or CronJob.
Why is the job eight hours late?
The container is probably UTC while the hour was written for Beijing. Change TZ or the hour, not both blindly.
Five vs six fields?
Five has no seconds. Six often adds seconds; seven adds a year. Linux crontab is five. Check before pasting from Java docs.
Is Sunday 0 or 1?
Often 0 or 7 is Sunday and 1 is Monday. Confirm in the crontab manual for your binary.
Does cron run exactly once?
No. Overlaps, DST, and manual reruns happen. Make the job reentrant or lock it.