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 are fine for personal Linux servers but avoid them in portable scripts, Dockerfiles, and anything that might run under BusyBox. Explicit expressions always work.

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 *. The catch: these shortcuts only work in system-level crontabs (/etc/crontab) and user crontabs on systems running Vixie cron or cronie (most Linux distributions). They don't work in BusyBox cron (Alpine Linux, minimal containers) or on macOS (which uses launchd, not cron, by default). For portable scripts and Docker containers, use explicit 5-field expressions.

Verdict

The eight shortcut strings (@reboot, @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly) work on Vixie cron and cronie, but not in BusyBox, which covers Alpine and minimal containers. macOS uses launchd instead. @reboot is the lone exception worth keeping because no numeric expression runs once after boot. For Dockerfiles and scripts that touch mixed systems, stick with explicit five-field expressions.

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?
Often not. Vixie cron and cronie on standard Linux support all eight shortcuts, but BusyBox cron - the daemon in Alpine Linux and most minimal container images - doesn't recognize them. The @daily line either errors out or is silently ignored depending on the version. For anything that ships in a Dockerfile, write the explicit 5-field expansion instead.