Cron expressions turn a simple scheduling requirement into a precise rule, but small differences in field order, time zones, and platform syntax can create missed runs or unexpected load. This guide explains Linux cron syntax, shows practical schedules for backups and CI/CD jobs, and gives you a repeatable process for building, testing, monitoring, and revisiting cron jobs safely.
Overview
A cron expression is a compact schedule made from fields that describe when a command may run. Traditional Linux and Unix cron commonly use five fields: minute, hour, day of month, month, and day of week.
| Field | Allowed values | Meaning |
|---|---|---|
| Minute | 0–59 | Minute within the hour |
| Hour | 0–23 | Hour of the day, usually in local server time |
| Day of month | 1–31 | Calendar day |
| Month | 1–12 | January through December |
| Day of week | 0–7 | Sunday is commonly 0 or 7; values 1–6 represent Monday through Saturday |
The asterisk means “any permitted value.” A comma lists separate values, a hyphen defines a range, and a slash defines a step. For example, 0,30 means at minute zero and minute thirty, 1-5 means values one through five, and */15 means every fifteen units within the field.
A standard entry has this general form:
minute hour day-of-month month day-of-week commandFor example:
30 2 * * * /usr/local/bin/backup.shThis requests a run at 02:30 every day according to the cron daemon's configured time zone. The expression itself does not guarantee that the command succeeds, finishes before the next run, or uses the same environment as an interactive shell.
Many browser-based tools can act as a cron builder or cron expression generator, which is useful for checking field positions and translating plain-language requirements into candidate expressions. Treat the result as a starting point: verify the target scheduler's syntax, time zone, and handling of special expressions before deploying it.
What to track
Reliable scheduling requires tracking more than the expression. Keep a small record for every recurring job so another engineer can understand its intent and verify its behavior.
1. The business or operational purpose
Write what the job is supposed to accomplish, such as “remove temporary files older than seven days” or “build the nightly test report.” A purpose statement makes an apparently strange schedule easier to evaluate when requirements change.
2. The exact schedule and time zone
Store the cron expression alongside a plain-language explanation. Record whether the job uses UTC, the server's local time, a container time zone, or a platform-specific scheduler setting. Do not assume that a developer laptop and production host interpret the same expression identically.
3. The command, working directory, and environment
Use absolute paths where practical. Cron may provide a limited PATH, may start in an unexpected working directory, and may not load the shell profile used by an interactive session. Make required environment variables explicit, and keep secrets in an appropriate secret-management system rather than embedding them in a crontab entry.
4. Runtime and overlap behavior
Track the expected duration, typical exit status, and whether two instances may safely run at the same time. A job that usually takes five minutes can become an overlapping-job problem after a data increase or a slow dependency. Add a lock, queue, or platform-native concurrency control when duplicate execution could cause damage.
5. Evidence of success
Define what success looks like: an output file with a recent timestamp, a completed database record, a deployment status, or a metric delivered to monitoring. A process that exits without an error is not always proof that the intended work completed.
For related operational checks, the Kubernetes configuration validation guide and DNS records troubleshooting guide provide useful examples of validating configuration and observing changes rather than trusting a configuration file alone.
Cadence and checkpoints
Build the schedule from the requirement, not from a memorized expression. Start by answering five questions: what should run, how often should it run, which time zone matters, what should happen if it is delayed, and how will you confirm success?
Common Linux cron schedule examples
| Expression | Intent |
|---|---|
*/5 * * * * | Every five minutes |
0 * * * * | At the start of every hour |
15 4 * * * | Daily at 04:15 |
0 6 * * 1-5 | At 06:00 Monday through Friday |
0 3 1 * * | At 03:00 on the first day of each month |
0 1 * * 0 | At 01:00 every Sunday |
0 0,12 * * * | At midnight and noon each day |
Use a schedule that leaves enough operational margin. A backup should not routinely compete with a batch import or a deployment window. For jobs that are expensive or disruptive, choose a quiet period and document why it was selected. For high-frequency jobs, consider whether an event-driven worker or queue is more appropriate than polling with cron.
Standard cron uses five scheduling fields, but some tools add a seconds field or use a different field order. CI/CD services may also require a special wrapper, a branch or workflow declaration, or a platform-specific schedule format. Confirm the documentation for the actual execution environment before copying a Linux expression into a pipeline configuration.
Time zones deserve an explicit checkpoint. A job scheduled near midnight or during daylight-saving transitions may not behave as a reader expects. If the platform allows it, choose and document a stable time zone such as UTC for infrastructure tasks. If the job must follow a local business time, test the transition behavior and decide whether skipped or repeated local times are acceptable.
How to interpret changes
When a scheduled job changes, compare four layers separately: the expression, the execution environment, the command, and the observed result. This prevents a timing problem from being mistaken for an application failure.
Expression changed, run count changed
First expand the expression into plain language and list the next several expected run times. Check commas, ranges, step values, and the placement of each field. A swapped minute and hour can create a valid expression that runs at the wrong time, making syntax validation alone insufficient.
Run occurred, output is missing
Inspect the command's exit status, standard output, standard error, permissions, working directory, and environment variables. Redirect output to a controlled log location or use the host's logging system. If the command invokes a script, test that script with the same user and absolute paths used by cron.
Runs are duplicated or overlap
Check whether the schedule was installed in more than one crontab, whether a deployment created a second scheduler, and whether a previous run can still be active. Add an explicit lock or concurrency policy where appropriate. Make jobs idempotent when possible, so retrying a completed operation does not corrupt data or send duplicate notifications.
Timing changed after deployment
Compare the time zone and clock configuration of the old and new hosts, containers, runners, or managed scheduler. Also check whether the CI/CD platform interprets schedules in a platform-defined time zone rather than the runner's local setting. For broader date and time troubleshooting, see the JavaScript date and time debugging guide; its principles around time zones and daylight-saving behavior apply to scheduled workflows as well.
For recurring maintenance, review dependency and runtime changes alongside the schedule. A script may fail after a package, shell, or operating-system update even though the cron expression is unchanged. The npm dependency and lockfile troubleshooting guide can help when a scheduled JavaScript task begins failing after dependency changes.
When to revisit
Revisit every production cron job at least during a monthly or quarterly operational review, with a closer check after any change to the host, application, data volume, deployment pipeline, or time-zone policy. A recurring schedule should be treated as configuration that can become stale, not as a one-time setup task.
Use this practical checklist:
- Translate the expression into plain language and confirm the next expected run times.
- Verify the scheduler's field count, special syntax, and time-zone behavior.
- Confirm the command still exists, has the required permissions, and uses explicit paths.
- Review recent duration, exit status, logs, output freshness, and overlap events.
- Check whether the job still matches current retention, backup, reporting, or deployment requirements.
- Run a controlled test or dry run before changing a high-impact schedule.
- Record the owner, purpose, last review date, and next review date.
Before editing a live job, copy its current configuration and identify a rollback path. After the change, verify both that the job runs when expected and that it produces the intended result. A cron builder or cron expression generator can help draft and compare schedules, but observation and documentation are what make the automation reliable over time.