TechCompare LogoTechCompare

Cron special strings: @reboot, @daily, @hourly and when to use them

@reboot is the one special string genuinely worth using because it has no numeric equivalent. @daily and friends work on Vixie cron, cronie, and standard BusyBox builds from 1.27 onward. Explicit expressions are still easier to move across custom builds and different cron implementations.

Most cron daemons support eight special strings as shorthand for common schedules: @reboot, @yearly, @annually, @monthly, @weekly, @daily, @midnight, and @hourly. They're easier to read than numeric expressions but hide important details about exactly when the job runs.

By TechCompare · Updated

Schedule pattern
Cron special strings
special-strings
Category
Common Patterns
Standard cron expression patterns

How this is calculated

@reboot runs once at system startup. It's uniquely useful because there's no numeric cron expression for run once after boot. @daily and @midnight both expand to 0 0 * * *. @hourly expands to 0 * * * *. @weekly expands to 0 0 * * 0. @monthly expands to 0 0 1 * *. @yearly and @annually both expand to 0 0 1 1 *. Vixie cron and cronie support these strings. BusyBox crond has also supported them through FEATURE_CROND_SPECIAL_TIMES since version 1.27, and that feature defaults to enabled. Custom builds can turn it off, and macOS uses launchd rather than cron by default, so explicit 5-field expressions remain the safest portable form.

Verdict

The eight shortcut strings (@reboot, @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly) work on Vixie cron and cronie. BusyBox crond supports them when FEATURE_CROND_SPECIAL_TIMES is enabled, which has been the default since version 1.27. macOS uses launchd instead. @reboot is the lone shortcut with no numeric equivalent. For scripts that cross different systems or custom builds, explicit five-field expressions remain the portable choice.

More Cron scenarios

Frequently asked questions

What does @reboot do in cron?
It runs the job once, every time the system boots. There's no numeric cron expression for 'after boot,' so @reboot is the one shortcut with no equivalent. It fires as soon as cron starts during the boot sequence, which is before most services are up, so jobs that need the network or a database should add their own wait loop or move to a systemd unit with proper dependencies.
What does @daily expand to in cron?
0 0 * * *, midnight every day in the server's local timezone. @midnight is an alias for the same thing. Likewise @hourly is 0 * * * *, @weekly is 0 0 * * 0 (Sunday), @monthly is 0 0 1 * *, and @yearly plus @annually both expand to 0 0 1 1 *.
Do cron special strings like @daily work in Docker containers?
It depends on the cron daemon and build. Vixie cron and cronie support all eight shortcuts. BusyBox crond supports them when FEATURE_CROND_SPECIAL_TIMES is enabled, which is the default in BusyBox 1.27 and later. A custom build can disable that feature, so the explicit 5-field expansion is still the safest choice for a Dockerfile that may change base images.