A reliable cron schedule starts with more than a string of symbols. This guide explains how to build, verify, and operate recurring jobs for backups, database cleanup, reports, API polling, serverless functions, and CI pipelines. Use the field reference, scenario checklists, timezone guidance, and troubleshooting steps before putting a schedule into production.
Overview
Cron is a compact way to describe when a recurring task should run. A traditional five-field cron expression uses this order:
| Field | Allowed values | Meaning |
|---|---|---|
| Minute | 0–59 | Minute within the hour |
| Hour | 0–23 | Hour of the day, usually in 24-hour time |
| Day of month | 1–31 | Calendar day |
| Month | 1–12 or names, depending on the platform | Month of the year |
| Day of week | 0–6 or 1–7, depending on the platform | Day of the week |
For example, 30 2 * * * means “run at 02:30 every day” when interpreted by a scheduler using the standard five-field format. The asterisk means “any value.” A comma creates a list, a hyphen creates a range, and a slash creates an interval:
0,30 * * * *runs at minute zero and minute thirty of every hour.0 9-17 * * 1-5is intended for the top of each hour during a weekday workday.*/15 * * * *runs every fifteen minutes in schedulers that support step values.
Not every app deployment platform, CI system, or serverless scheduler implements the same dialect. Some accept only five fields; others accept a sixth field for seconds. Some use a named timezone, some use UTC by default, and some provide a separate timezone setting. Treat the expression and its execution environment as one configuration item.
An online cron expression builder can help translate plain language into fields, but it should be treated as a verification aid rather than a substitute for reading the target provider’s documentation. Always test the resulting schedule in the system where it will run.
Checklist by scenario
Daily backups
- Choose a low-traffic window, but confirm that the database and application can tolerate the backup workload at that time.
- Write the intended timezone in the job description, not only in a team member’s local notes.
- Check whether the backup command is safe to repeat after a timeout or partial failure.
- Send a success or failure signal to a log, alerting system, or operations channel.
- Define retention and cleanup separately if old backups should be removed automatically.
A schedule such as 0 1 * * * may express “01:00 every day,” but it does not by itself guarantee that the job finishes, that the backup is restorable, or that two instances cannot overlap.
Database cleanup
- Specify exactly which records qualify for deletion or archival.
- Use a bounded batch size when the dataset may grow substantially.
- Consider whether indexes, locks, and transaction duration will affect production traffic.
- Make the operation idempotent where possible, so a retry does not cause unintended damage.
- Run a dry-run or reporting mode before enabling deletion.
For example, 15 3 * * 0 is commonly read as 03:15 every Sunday in a five-field scheduler, but day-of-week numbering can vary. Verify whether the target system treats Sunday as 0, 7, or both.
Reports and notifications
- Confirm that source data has completed its daily ingestion before generating the report.
- Use a fixed timezone for the reporting period, especially when recipients work across regions.
- Define what happens when there is no data, incomplete data, or a downstream email failure.
- Include the scheduled period in the report so recipients can identify late or duplicate runs.
API polling
- Check the API’s rate limits and choose an interval that does not create unnecessary load.
- Store a cursor, timestamp, or event identifier so retries do not duplicate processing.
- Handle pagination, timeouts, authentication expiry, and temporary failures.
- Use backoff for failed requests rather than immediately starting another aggressive polling cycle.
Serverless functions and CI pipelines
- Confirm whether the platform expects a cron expression, a YAML schedule, or a provider-specific wrapper.
- Check the maximum execution time and whether the scheduler waits for completion.
- Prevent overlapping deployments, migrations, or maintenance jobs with a lock or concurrency control.
- Ensure required secrets and environment variables are available in the scheduled execution context.
- Record the job identifier, scheduled time, actual start time, and completion status.
For broader deployment choices, compare the operational differences in Render and Railway full-stack deployment or review Vercel and Netlify production workflows. The scheduler’s syntax is only one part of the deployment decision.
What to double-check
Timezone and daylight-saving behavior
“Every day at 09:00” is incomplete unless the timezone is known. UTC is often a predictable choice for infrastructure tasks, while business reports may need a named regional timezone. Avoid relying on an unlabeled server-local timezone.
Daylight-saving transitions can create a local time that occurs twice or does not occur at all. A job scheduled at a transition hour might run once, twice, or be skipped, depending on the scheduler. For critical tasks, read the provider’s documented behavior, test the transition if practical, and decide whether UTC or a business timezone better matches the requirement.
Expression dialect
Check these details before copying an expression between systems:
- Five fields versus six fields with seconds.
- Whether month and weekday names are supported.
- Whether
?,L,W, or hash-style weekday syntax is supported. - How Sunday is numbered.
- Whether the day-of-month and day-of-week fields use “either field” or “both fields” semantics when both are restricted.
- Whether schedules run at a fixed interval or only at wall-clock times.
Execution guarantees
A cron expression describes an attempted invocation, not a guaranteed successful completion. Ask whether the platform retries failures, skips missed invocations, queues delayed runs, or permits concurrent executions. If the job matters, add application-level safeguards: idempotency keys, distributed locks, checkpoints, bounded retries, and alerts.
When a scheduled task consumes or produces structured payloads, validate the input and output as part of the job. A JSON formatter and validator can help inspect malformed API responses, while a JWT debugging guide is useful when an automated request fails because of claims or expiration.
Common mistakes
- Confusing “every five minutes” with “at minute five.”
*/5 * * * *means every five minutes;5 * * * *means once per hour at minute five. - Using the wrong hour format. Cron normally uses 24-hour time. “7 PM” is represented as hour 19, not 7.
- Forgetting the deployment timezone. A locally correct expression can run at an unexpected hour in production.
- Assuming a job cannot overlap. A slow run and a new scheduled invocation may execute simultaneously unless concurrency is controlled.
- Ignoring missed runs. Deployments, suspended services, and platform outages may cause an invocation to be skipped or delayed.
- Testing only the expression. A schedule can be valid while its command fails because of permissions, missing secrets, an incorrect working directory, or an unavailable dependency.
- Making destructive jobs irreversible. Add dry-run support, backups, audit logs, and a recovery plan before automating deletion.
When to revisit
Review scheduled jobs before seasonal planning cycles, timezone changes, major release windows, and infrastructure migrations. Also revisit them whenever a workflow, database, API, CI system, or serverless provider changes. A platform update may alter supported syntax, timezone settings, retry behavior, execution limits, or concurrency defaults.
Use this short operational review:
- Write the schedule in plain language, including its timezone.
- Confirm the expression against the target scheduler’s current syntax.
- Calculate several upcoming run times, including a daylight-saving transition if relevant.
- Run the task manually in a safe environment and verify its output.
- Check logs, alerts, retries, and overlap protection.
- Document the owner, purpose, dependencies, and rollback or recovery procedure.
- Record the last review date and the next trigger for reviewing it again.
For recurring jobs that support an app, treat the cron expression as production code: keep it in version control where possible, review changes, and monitor actual runs. That habit turns a convenient schedule into a dependable part of your application workflow.