FreeAI.DevTools

Cron: Daily at Midnight

The cron expression for "daily at midnight", what each field means, and the next run times on your clock.

What is the cron expression for daily at midnight?

0 0 * * * runs once per day at 00:00. Minute 0 and hour 0 pin the time to midnight, and the three trailing wildcards match every day of the month, every month, every weekday. Cron evaluates it in the server's local timezone, so a UTC host fires at midnight UTC.

0 0 * * *

At 12:00 AM

Next 5 runs (your timezone)

The default home of nightly maintenance

Midnight is where operational housekeeping traditionally lives: rotating and compressing the day's logs, taking a database dump before the backup window, expiring stale sessions, and rebuilding nightly aggregates for yesterday's data. The appeal is a clean day boundary; a dump taken at 00:00 contains exactly one calendar day's writes, which makes restores and audits easier to reason about.

The same convenience creates a pile-up. When the backup, the log rotation, and three application jobs all start at 00:00 sharp, they compete for the same disk and CPU. Spreading them across 0 0, 20 0, and 40 1 keeps each one fast while preserving the nightly rhythm.

Timezones and daylight saving

Cron reads the system clock in local time unless the daemon supports a CRON_TZ variable, so 0 0 * * * on a server set to America/New_York means midnight Eastern, not UTC. Container images almost always default to UTC, which is why a job that ran at midnight on the old VM suddenly runs at 19:00 or 20:00 local after a move to Kubernetes.

Midnight itself is fairly DST-safe because most zones shift their clocks between 01:00 and 03:00, hours after this job has fired. Schedules inside that window inherit real risk: a 02:30 job can be skipped on spring-forward night or run twice on fall-back night, with the exact behavior varying by cron implementation.

Frequently asked

What timezone does cron use?
The system's local timezone by default. Some implementations, including modern Vixie derivatives and cronie, honor a CRON_TZ or TZ variable set inside the crontab to evaluate schedules in another zone. When timing matters across regions, run the host in UTC and convert at the edges.
Are @daily and @midnight the same as 0 0 * * *?
Yes, crontab(5) defines both nicknames as 0 0 * * *. They fire once per day at 00:00 local time. As with all nicknames, portability varies, so the five-field form is the safe choice for CI systems and Kubernetes.
Can daylight saving make my midnight job skip or double?
Rarely at midnight, since most zones transition around 02:00 or 03:00. The affected window is the transition hour itself: jobs scheduled there may skip on spring-forward or repeat on fall-back, depending on the daemon. Scheduling in UTC removes the problem entirely.

More in this series

// The subscription desk

The Inference Report

The weekly briefing for AI engineers: model releases, pricing moves, benchmarks, and the news that changes what you should build with and what it costs. Every Tuesday, 5-minute read. No fluff.

Join AI engineers who stopped overpaying for tokens. Unsubscribe anytime.