A cron expression is a compact way to describe when a recurring command should run. This guide explains how to read each field, build reliable schedules, verify them with a cron expression generator, and account for time zones, daylight-saving changes, Linux behavior, and CI/CD platform differences.
Overview
A standard Linux cron schedule contains five time fields followed by the command to execute:
minute hour day-of-month month day-of-week command
For example:
30 2 * * 1 /opt/scripts/backup.sh
Read this from left to right as “at 02:30 on every Monday, run the backup script.” The five fields are:
- Minute: 0 through 59
- Hour: 0 through 23, using a 24-hour clock
- Day of month: 1 through 31
- Month: 1 through 12, or names such as
jananddecwhere supported - Day of week: commonly 0 through 7, where both 0 and 7 can represent Sunday; names such as
monandsunmay also be supported
An asterisk means “every valid value.” Thus, * * * * * matches every minute. That pattern is useful for understanding syntax but is usually too frequent for a production task.
Cron expressions are interpreted by an implementation, not by a universal standard. Linux distributions, container images, hosted CI systems, cloud schedulers, and online developer tools can differ in supported fields, time-zone handling, special shortcuts, and minimum intervals. Before deploying a schedule, confirm the syntax and time behavior of the target system.
What to track
Build expressions from the fields
Use these operators to construct a Linux cron schedule:
*matches every allowed value. In the hour field,*means every hour.,defines a list.0 8,12,16 * * *runs at 08:00, 12:00, and 16:00 every day.-defines an inclusive range.0 9 * * 1-5runs at 09:00 on weekdays./defines steps.*/15 * * * *matches every 15 minutes, while0 */4 * * *runs at the start of every fourth hour.
Combine operators when the schedule needs a precise window. For example:
0 6-18/2 * * 1-5 /opt/scripts/check.sh
This means at minute zero, every two hours from 06:00 through 18:00, Monday through Friday.
Keep a reference schedule nearby
| Purpose | Expression | Meaning |
|---|---|---|
| Every five minutes | */5 * * * * | Runs at minutes 0, 5, 10, and so on |
| Every day at midnight | 0 0 * * * | Runs at 00:00 each day |
| Every day at 23:30 | 30 23 * * * | Runs once per day late at night |
| Every Monday at 09:00 | 0 9 * * 1 | Runs weekly on Monday |
| First day of each month | 0 3 1 * * | Runs at 03:00 on day 1 |
| Weekdays at 18:00 | 0 18 * * 1-5 | Runs Monday through Friday |
Be careful when combining day-of-month and day-of-week. In many traditional cron implementations, if both fields contain restricted values, the job can run when either condition matches rather than only when both match. For instance, 0 9 1 * 1 may run on the first day of the month and on Mondays. Because this behavior is easy to misread and can vary across schedulers, test the exact implementation or use separate jobs for separate rules.
Track the command as carefully as the schedule
A correct expression does not make an unreliable job safe. Record the command, working directory, expected runtime, output destination, and failure behavior alongside the schedule. Cron often runs with a limited environment, so use absolute paths for executables and files, define required environment variables explicitly, and send output to a log or monitored destination.
For destructive operations, add safeguards in the script rather than relying on the schedule alone. A backup job, for example, should define retention and verify that the destination is available before deleting older data.
Cadence and checkpoints
Use a repeatable verification process whenever you create or modify a schedule:
- Write the requirement in plain language. State the intended local time, days, frequency, and acceptable delay before writing fields.
- Translate one field at a time. Check the minute and hour first, then add day, month, and weekday restrictions.
- Inspect the next several run times. A cron expression generator or local testing utility can expose mistakes such as an unexpected weekday, month boundary, or interval.
- Test the command independently. Run the script with the same user, permissions, paths, and configuration that the scheduler will use.
- Perform a controlled scheduled run. Use a harmless command or a staging target before enabling production changes.
- Record ownership and evidence. Note who maintains the job, where logs appear, what success looks like, and how to disable it.
For CI/CD scheduled jobs, treat the workflow file as code. Review the event syntax, branch or ref selection, permissions, secrets, runner availability, and concurrency behavior in addition to the cron expression. A scheduled workflow can be syntactically valid but still run against the wrong branch or overlap with an earlier execution.
Many hosted CI systems interpret schedules in UTC, and some may queue a scheduled run later than its nominal time. Do not assume that a Linux server's local time zone applies to a hosted runner. If a business process requires a local wall-clock time, document the chosen time zone and verify the platform's behavior. For jobs tied to billing, market windows, reporting deadlines, or regional operations, consider an explicit time-zone-aware scheduler instead of encoding assumptions into a five-field cron pattern.
How to interpret changes
When a recurring job behaves differently, compare the observed run time with the expression before changing the schedule. The cause may be an incorrect field, a time-zone conversion, daylight-saving time, a delayed runner, a locked host, or a command that started on time but finished later than expected.
Daylight-saving transitions deserve special attention. A local time that occurs twice can produce two apparent opportunities, while a local time that is skipped may not run as expected. A schedule expressed in UTC avoids some local-clock ambiguity, but it may shift relative to local business hours. Choose deliberately and document the choice.
Also distinguish “every N minutes” from “at fixed clock minutes.” The expression */20 * * * * matches minute 0, 20, and 40 of each hour; it does not mean 20 minutes after the previous run completes. If a task takes longer than its interval, concurrent executions may accumulate. Add a lock, concurrency control, or idempotent job design where overlap would be harmful.
When auditing an existing schedule, check these signals:
- The next-run preview does not match the plain-language requirement.
- Logs show runs at a different time after a host, runner, or region change.
- Two executions overlap or create duplicate notifications and records.
- Month-end, leap-day, or weekday behavior is missing from tests.
- The command succeeds manually but fails under the scheduler's user or environment.
- A platform migration changes supported syntax or time-zone defaults.
If the schedule is difficult to explain in one sentence, split it into smaller jobs or move the logic into a script with explicit date handling. Readability is an operational control: the next maintainer should be able to identify the intended cadence without reverse-engineering it.
When to revisit
Revisit cron schedules whenever the command, host, runner, deployment branch, operating system, or business requirement changes. Put a lightweight review on a monthly or quarterly operations checklist for important jobs, even when nothing appears to be wrong.
At each review, confirm the expression against its plain-language description, inspect recent success and failure logs, verify that the owner and destination still exist, and check whether runtime has approached the next scheduled start. Test boundary cases such as month changes, daylight-saving transitions, and weekends when they matter to the job.
Use this practical checklist before enabling or editing a schedule:
- Write the desired cadence and time zone in plain language.
- Confirm the target scheduler's field count, operators, and special syntax.
- Preview several upcoming run times with a trusted cron expression generator or platform tool.
- Use absolute paths and define the runtime environment.
- Test the command safely and verify permissions, secrets, and network access.
- Decide how failures, retries, timeouts, and overlapping runs are handled.
- Document the owner, logs, disable procedure, and next review date.
For related release automation, see the guide to debugging GitHub Actions pipeline failures. If a scheduled job deploys infrastructure or workloads, pair its review with a Kubernetes upgrade checklist or a documented rollback plan. A cron expression is only one small part of dependable automation; clear intent, safe execution, and recurring verification make the schedule maintainable.