A reliable cron expression starts with more than a pattern copied from a generator. This guide explains how to create and validate recurring schedules, choose the right syntax for Linux and cloud schedulers, account for time zones and daylight-saving changes, and use a practical checklist before putting automation into production.
Overview
Cron is a compact scheduling format used to run a command or job at recurring times. A traditional Unix-like cron entry has five fields:
| Field | Allowed values | Meaning |
|---|---|---|
| Minute | 0–59 | Minute of the hour |
| Hour | 0–23 | Hour in 24-hour time |
| Day of month | 1–31 | Calendar day |
| Month | 1–12 or names | Month of the year |
| Day of week | 0–7 or names | Sunday through Saturday; 0 and 7 commonly represent Sunday |
The fields are read from left to right. For example, 30 2 * * 1 means “at 02:30 every Monday” in the scheduler’s configured time zone. An asterisk means every valid value, while a comma lists specific values, a hyphen defines a range, and a slash defines an interval. Thus, 0,30 means at minutes zero and thirty, 1-5 means values one through five, and */15 means every fifteen units.
A cron expression generator can help you create a pattern, but it cannot decide whether the schedule matches the business requirement. Treat the generated expression as a draft: identify the intended time zone, confirm the scheduler’s dialect, and test several future occurrences before deployment.
Checklist by scenario
Hourly and interval jobs
0 * * * *— run at the start of every hour.*/15 * * * *— run every fifteen minutes.5-55/10 * * * *— run every ten minutes from minute five through minute fifty-five.
Use an explicit minute when a job should run once per hour. Use an interval only when repeated execution within the hour is intentional. Also check whether overlapping runs are possible; a scheduler may start a new invocation before the previous one finishes.
Daily jobs
0 0 * * *— run daily at midnight.30 6 * * *— run daily at 06:30.0 9 * * 1-5— run at 09:00 on weekdays.
Prefer 24-hour notation and document the intended local time beside the expression. “Midnight” is especially easy to misinterpret, so write whether the job should run at the start of the day or at 12:00 noon.
Weekly jobs
0 18 * * 5— run at 18:00 every Friday.15 8 * * 1— run at 08:15 every Monday.0 3 * * 0— run at 03:00 every Sunday in systems where 0 represents Sunday.
Day names may be easier to read, but numeric values are often more portable. Confirm whether the scheduler treats Sunday as 0, 7, or both before moving an expression between platforms.
Monthly jobs
0 1 1 * *— run at 01:00 on the first day of each month.0 4 15 * *— run at 04:00 on the fifteenth day of each month.0 2 1 1,4,7,10 *— run at 02:00 on the first day of January, April, July, and October.
Cron does not provide a universal “last day of the month” expression. For that requirement, schedule a frequent check and let the command determine whether today is the final calendar day, or use a scheduler feature that explicitly supports calendar conditions.
Linux and cloud schedulers
On Linux, a user crontab commonly uses five scheduling fields followed by a command. A system-wide file such as /etc/crontab can include an additional user field, so do not copy entries between those locations without checking the expected format.
Cloud schedulers frequently resemble Unix cron but are not interchangeable. Some use a six-field format, add a year field, or support a question mark for an unspecified day field. Others require a configured time zone, use UTC by default, or impose their own limits on frequency. Before deploying, read the target service’s expression reference and test its preview or dry-run facility. For a broader collection of browser-based utilities, see the Online Developer Tools Toolkit.
What to double-check
- Dialect: Confirm the number and order of fields, supported names, special characters, and whether seconds are included.
- Time zone: Record the scheduler’s zone next to the expression. A correct pattern in UTC can be wrong for a team working in another region.
- Day-of-month behavior: In many traditional cron implementations, when both day-of-month and day-of-week are restricted, a match in either field can trigger the job rather than requiring both. Verify this behavior instead of assuming an AND relationship.
- Calendar limits: Check what happens on months without a requested date, such as the thirty-first. The job may simply not run in shorter months.
- Daylight saving time: A local time can occur twice or not occur at all when clocks change. Decide whether duplicate execution is acceptable and make jobs safe to retry.
- Execution environment: Use absolute paths where appropriate, define required environment variables, and confirm the service account has the necessary permissions.
- Observability: Capture logs, failure notifications, and the actual start time. A schedule is difficult to troubleshoot when successful and missed runs leave no record.
A useful validation workflow is: write the plain-language requirement, select the target scheduler, generate or compose the expression, inspect the next several run times, test boundary dates, run the command manually with the production-like identity, and document the final expression with its time zone.
Common mistakes
- Reversing minute and hour:
6 30 * * *is 30:06, not 06:30. The correct five-field form is30 6 * * *. - Using the wrong field count: A six-field cloud expression may be rejected by Linux cron, while a five-field expression may be incomplete for a scheduler that requires seconds or a year.
- Assuming local time: The host, container, and managed scheduler may each use different time-zone settings.
- Scheduling the thirty-first: A monthly job on day 31 will not run in shorter months unless additional logic handles that case.
- Ignoring retries and overlap: Make operations idempotent, use locks where needed, and define how a failed or delayed run is recovered.
- Putting secrets in the command: Keep credentials in the platform’s secret or environment mechanism rather than exposing them in crontab text or process arguments.
When to revisit
Review a cron expression whenever the job, platform, or calendar assumptions change. Recheck schedules before seasonal planning cycles, after a server or cloud migration, when the business time zone changes, and before introducing jobs around daylight-saving transitions. Also revisit expressions when a command gains new runtime requirements, when execution time increases, or when missed-run alerts reveal an ambiguous schedule.
Keep a small schedule record containing the plain-language intent, expression, scheduler name, time zone, owner, expected runtime, and recovery procedure. During an audit, validate the next occurrences again rather than relying only on a string comparison. If the platform changes its cron syntax or adds a calendar feature, update the record and test in a non-production environment first.
Before saving any new schedule, use this final checklist: correct dialect, correct time zone, correct field order, expected next runs, safe behavior at month and DST boundaries, documented ownership, and observable failures. That routine turns a fragile copied pattern into a maintainable automation rule.