Cron expressions can make AI workflow automation predictable, but a schedule that looks correct may still run at the wrong local time, overlap with an earlier job, or silently miss work after a failure. This guide explains how to write cron schedules for recurring AI jobs, account for time zones and daylight-saving changes, and add safe retry and monitoring practices. Use the checklists before deploying a new schedule, migrating schedulers, or investigating a missed or duplicate run.
Overview
A cron expression describes when a recurring job should start. Traditional Unix and Linux cron commonly use five fields, read from left to right:
| Field | Allowed values | Meaning |
|---|---|---|
| Minute | 0–59 | Minute of the hour |
| Hour | 0–23 | Hour of the day |
| Day of month | 1–31 | Calendar day |
| Month | 1–12 or names, depending on the scheduler | Month of the year |
| Day of week | 0–7 or names, depending on the scheduler | Day of the week; Sunday is often 0 or 7 |
The basic operators are useful across many cron implementations:
- Asterisk (
*): every permitted value, such as every minute or every hour. - Comma (
,): a list of values, such as1,15for the first and fifteenth day. - Hyphen (
-): an inclusive range, such as1-5for Monday through Friday when the scheduler uses that numbering. - Slash (
/): an interval, such as*/15for every fifteen minutes.
Not every platform uses exactly the same syntax. Some cloud schedulers, CI systems, and workflow platforms add a seconds field, use a six-field format, support a question-mark placeholder, or interpret time zones through a separate configuration setting. Treat the scheduler's documented format as authoritative rather than assuming that a Linux expression will transfer unchanged.
Checklist by scenario
Run an AI pipeline every day
For a daily document classification, embedding, or report-generation job, choose an explicit hour and minute. In standard five-field cron, 30 2 * * * means 02:30 every day in the scheduler's configured time zone. Before using it, confirm whether 02:30 is a suitable period for database load, API quotas, and downstream availability.
- Define whether “day” means a calendar day in UTC or in a business location.
- Make the job idempotent, so a rerun does not duplicate records or send repeated messages.
- Record the intended schedule in the runbook using plain language as well as the expression.
- Set a completion deadline and alert if the job has not finished by that time.
Run during business days
A weekday schedule such as 0 9 * * 1-5 is commonly read as 09:00 from Monday through Friday. Verify weekday numbering before deployment: some systems accept Sunday as 0 or 7, while others also accept names. If the job serves multiple regions, one weekday expression may not represent every region's working day or holiday calendar.
- Confirm the scheduler's definition of Monday and Sunday.
- Separate weekday timing from holiday exclusions unless the platform explicitly supports a calendar.
- Test the expression at the boundary between Sunday and Monday.
Run monthly or on selected dates
To run at 06:00 on the first day of every month, use 0 6 1 * * in a conventional five-field format. To run on the first and fifteenth, use 0 6 1,15 * *. Be cautious with dates such as the 31st: a schedule like 0 6 31 * * cannot run in shorter months, and platform behavior for invalid dates may differ.
- Decide whether an absent calendar date should be skipped or replaced with the last day of the month.
- Test month boundaries, leap years, and the first run after a deployment.
- Prefer an application-level calendar rule when the business requirement is more complex than cron syntax.
Run frequently without creating a backlog
An expression such as */10 * * * * requests a run every ten minutes. That does not guarantee that each run will finish before the next one begins. For AI workloads, variable model latency, batch size, rate limits, and queue delays can make overlap likely.
- Estimate the longest normal runtime, not only the average runtime.
- Use a distributed lock, queue consumer, or concurrency limit where supported.
- Choose a policy for a tick that arrives while the previous run is active: skip, queue, or coalesce it.
- Track scheduled time, start time, completion time, and input watermark separately.
Retry a failed workflow
Cron itself is usually a trigger, not a complete retry system. A robust design separates the schedule from execution state. The scheduled command should create or request a specific job, while the worker records attempts, errors, and completion status.
- Assign each scheduled run a stable identifier, such as the intended interval or date.
- Retry transient failures with bounded exponential backoff rather than starting unlimited copies.
- Use an idempotency key when writing results or sending external notifications.
- Send permanently failed items to a review queue or dead-letter store.
- Alert on repeated failures, not only on process crashes.
What to double-check
Time zones and daylight-saving changes
A cron expression has no universal time zone by itself. The scheduler may use the host's local zone, UTC, a per-job setting, or a platform-wide default. Write the intended zone beside every production schedule, for example: “02:30 Europe/London” or “09:00 UTC.” Avoid relying on an undocumented server default.
Daylight-saving transitions create two edge cases. During a spring transition, a local clock time may not exist; during an autumn transition, a local time may occur twice. Platforms differ in whether they skip, repeat, or normalize such runs. If an AI pipeline must run exactly once per business date, schedule in UTC and apply business-date logic in the application, or use a scheduler with an explicit time-zone and calendar model. Test both transition dates for every supported region.
Scheduler dialect
Before copying an expression, check the number and order of fields, support for names, the meaning of Sunday, whether seconds are required, and how special characters are escaped. A cloud scheduler may require a quoted expression or a separate time-zone parameter. A CI platform may use a repository-level schedule and may not run when the system is inactive. A workflow tool may interpret a cron trigger in UTC even when its user interface displays local time.
Missed and duplicate runs
Ask what happens when the scheduler is unavailable, the host restarts, a deployment overlaps the trigger, or the job exceeds its interval. Some systems do not backfill missed runs; others provide catch-up behavior. Duplicate delivery is also possible after a timeout when the scheduler cannot tell whether the worker completed. Design for at-least-once triggering by making processing safe to repeat, then monitor for missing intervals.
Common mistakes
- Confusing “every five hours” with a fixed daily time:
0 */5 * * *runs at hours divisible by five, not necessarily five hours after the previous run. - Using local time without naming the zone: a server migration can change the effective schedule.
- Assuming a five-field expression works everywhere: field counts and special operators vary.
- Scheduling at midnight without considering date boundaries: records written near midnight can be assigned to different reporting dates.
- Allowing overlapping workers: duplicate AI inference, exports, or notifications can increase cost and corrupt downstream state.
- Retrying the entire pipeline blindly: a failed final step may repeat successful earlier steps unless stages have checkpoints.
- Testing only the expression: a valid schedule can still fail because credentials, network access, model quotas, input data, or output storage are unavailable.
When to revisit
Review a cron schedule before seasonal planning cycles, regional time changes, or any period when reporting deadlines shift. Revisit it whenever the workflow, AI model, input volume, destination system, scheduler, or deployment environment changes. A migration from host-based cron to a cloud scheduler deserves a full syntax, time-zone, and failure-semantics review rather than a direct copy and paste.
Use this pre-deployment checklist:
- Write the requirement in plain language, including the intended time zone.
- Confirm the scheduler dialect, field count, weekday numbering, and special operators.
- Validate the expression with representative dates, month boundaries, and daylight-saving transitions.
- Test a controlled run and inspect logs, permissions, inputs, outputs, and notifications.
- Define concurrency, timeout, retry, backoff, and missed-run behavior.
- Verify idempotency and add a run identifier to every execution.
- Document the owner, expected duration, alert threshold, and rollback procedure.
Keep the expression, plain-language description, time-zone setting, and operational assumptions together in the automation runbook. When a scheduled AI job is missed or duplicated, compare the intended schedule with the scheduler's actual interpretation, then inspect execution state before adding another trigger. This small discipline makes recurring jobs easier to operate as workflows and tools evolve.