Reference

Cron macros.

Cron macros are shorthand for common schedules — @daily, @hourly, @weekly, etc. They work on Linux and most Unix cron implementations, but NOT on AWS EventBridge, GitHub Actions, or Kubernetes CronJob.

Complete list

MacroEquivalent expressionMeaning
@yearly0 0 1 1 *Once a year, January 1 at midnight
@annually0 0 1 1 *Same as @yearly
@monthly0 0 1 * *1st of every month at midnight
@weekly0 0 * * 0Sunday at midnight
@daily0 0 * * *Every day at midnight
@midnight0 0 * * *Same as @daily
@hourly0 * * * *Top of every hour
@reboot(no expansion)Once at system startup

Platform support

PlatformStandard macros@reboot
Vixie cron (most Linux)
cronie (RHEL/CentOS/Fedora)
BSD cron✗ (usually)
Spring @Scheduled✓ (some)
Quartz
AWS EventBridge
GitHub Actions
Kubernetes CronJob
Jenkins

If you're not sure, use the explicit form. 0 0 * * * works everywhere; @daily doesn't.

The @reboot quirk

@reboot fires once at system startup. It's useful for starting long-running processes that aren't real services:

@reboot /usr/local/bin/start-my-tunnel.sh

Caveats:

  • Only available on Vixie cron and cronie — NOT on BSD or most container cron implementations
  • Fires AFTER cron starts, which may be later than you expect — typically after multi-user.target on systemd, so all standard services are up
  • For better startup ordering, use a real systemd service unit instead

Spring's macro support (limited)

Spring's @Scheduled cron parser accepts most macros but treats them slightly differently:

@Scheduled(cron = "@daily")           // Works
@Scheduled(cron = "@hourly")          // Works
@Scheduled(cron = "@reboot")          // Does NOT work
@Scheduled(cron = "@annually")        // May not work — use @yearly

When in doubt, use the explicit 6-field form: @Scheduled(cron = "0 0 0 * * *") for daily.

Why not just always use macros?

Three reasons to prefer explicit expressions over macros:

  1. Portability. Explicit expressions work on every cron implementation
  2. Flexibility. Macros are fixed times; 0 0 * * * is easy to modify to 0 3 * * *
  3. Off-peak scheduling. @daily means midnight UTC, which is the most contested moment of the day for cloud servers. Pick something like 13 3 * * * instead to avoid stampedes
Related

Continue reading.