Skip to content

Cron @midnight Macro: Meaning, Equivalent Expression & Platform Support

@midnight Every day at 00:00 special

The @midnight macro is a shorthand recognized by most modern cron implementations (Vixie cron, cronie, BusyBox crond and the robfig/cron library used by Kubernetes). It is exactly equivalent to the five-field expression 0 0 * * *. Macros exist for readability: '@daily' communicates intent more clearly than '0 0 * * *' at a glance, and they are immune to off-by-one mistakes when colleagues edit the schedule. Support is not universal, though — older or embedded cron daemons may reject macros outright, and the Java Quartz and AWS EventBridge ecosystems have no macro syntax at all, so portable infrastructure-as-code usually expands them to plain fields. Before adopting a macro in production, check your daemon's documentation: cronie and Vixie cron have supported these aliases for decades, but minimal implementations such as BusyBox crond historically accepted only a subset, and a rejected macro line can silently disable the whole crontab entry rather than just the one job. When you target multiple platforms, keep the macro in developer-facing crontabs and use the expanded form in generated configs. The table below shows the equivalent expression, the field breakdown, the next five computed run times where a clock schedule exists, and the exact Quartz, Spring, Kubernetes and EventBridge renderings.

Advertisement
Ad slot · ref-top

Field-by-field breakdown

FieldValueMeaning
minute0only at minute 0
hour0only at hour 0
day-of-month*every day-of-month (wildcard, no restriction)
month*every month (wildcard, no restriction)
day-of-week*every day-of-week (wildcard, no restriction)

Next 5 run times (UTC)

Computed at build time; cross-check against your server's time zone before deploying.

  • 2026-12-06 00:00 UTC
  • 2026-12-07 00:00 UTC
  • 2026-12-08 00:00 UTC
  • 2026-12-09 00:00 UTC
  • 2026-12-10 00:00 UTC

When to use this schedule

  • Developer-facing crontabs where readable intent ('@daily') matters more than raw field syntax.
  • Boot-time initialization (@reboot): warming caches, mounting volumes, starting supervision trees.
  • Infrastructure-as-code that expands macros to plain fields for platforms without macro support.
  • Quick prototypes and documentation examples where the canonical shorthand is the clearest form.

Equivalent syntax

The same schedule expressed for popular schedulers and platforms:

Crontab (5-field)
@midnight /usr/local/bin/job.sh   # Every day at 00:00
Quartz (6/7-field)
0 0 0 * * ?   # Quartz (Java): 6-7 fields, leading seconds, '?' when day-of-week is set
Spring @Scheduled
0 0 0 * * *   # Spring @Scheduled: 6 fields, leading seconds, day names accepted
Kubernetes CronJob
@midnight   # Kubernetes CronJob schedule field: standard 5-field syntax
AWS EventBridge
cron(0 0 * * ? *)   # AWS EventBridge: 6 fields incl. year, '?' required in one day field

Caveats & gotchas

  • Cron evaluates schedules in the server's local time zone; set CRON_TZ (cronie) or TZ (containers) explicitly on shared or distributed infrastructure.
  • Macros are a convenience layer: some minimal cron daemons reject them, and Quartz/EventBridge require the expanded five/six-field form.
  • When both day-of-month and day-of-week are restricted, standard cron ORs them; keep one of the two as '*' unless you want that behavior.

Verify your schedule

After installing the schedule, verify it end to end instead of trusting the crontab line. Run 'crontab -l' to confirm the entry survived editing, then execute the command manually with the same user and environment to catch PATH and permission problems — cron runs with a minimal environment, so absolute paths and explicit SHELL/PATH declarations prevent the classic 'works in my terminal, fails in cron' bug. Watch the daemon log ('grep CRON /var/log/syslog' on Debian/Ubuntu, 'journalctl -u cron' or '-u crond' on systemd hosts) to confirm the trigger fires at the expected times, and redirect the job's own output to a log file with 2>&1 so failures are not swallowed by mail. Finally, cross-check the next run times listed on this page against your server's time zone before declaring the schedule correct.

Frequently asked questions

What does @midnight mean in crontab?

It is shorthand for 0 0 * * *. Most modern cron daemons expand macros before parsing.

Does Kubernetes support @midnight?

Yes — the robfig/cron parser behind Kubernetes CronJob accepts @midnight and the other standard descriptors.

What is the Quartz equivalent of @midnight?

Quartz has no macros; use the expanded six-field form 0 0 0 * * ? shown in the examples table.

Advertisement
Ad slot · ref-in-article

Try the Cron Parser

Decode cron schedules and preview the next run times.

Open tool →