Run a Cron Job at Boot with @reboot
To run something once each time the machine starts, replace the five time fields with the special string @reboot. The line @reboot /home/me/startup.sh runs that script a single time at every boot. It does not repeat and it is not tied to a clock time.
The syntax
@reboot /usr/bin/python3 /home/me/startup.py
No minute/hour fields — @reboot replaces all five. The job runs once when cron starts at boot.
Common gotchas
- Environment is bare. At boot even less is set up than usual; always use absolute paths and, if needed, set variables inside the script.
- Network may not be ready. cron's @reboot can fire before the network is up. If the job needs the network, add a short
sleep 30at the top of the script or use a systemd unit withAfter=network-online.targetinstead. - Not for services. For a long-running daemon that must restart on crash, a systemd service is more reliable than @reboot.
Delay after boot
To wait before running, sleep inside the script: @reboot sleep 60 && /home/me/startup.sh. This gives the system a minute to settle.
FAQ
How do I make a cron job run at startup?
Use @reboot in place of the five time fields, e.g. @reboot /path/to/script.sh. It runs once every time cron starts at boot.
Does @reboot run at a specific time?
No. @reboot has no relation to the clock — it fires once when the cron daemon starts after a boot, whenever that happens.
My @reboot job needs the network but fails at boot. What do I do?
cron may start before networking is ready. Add sleep 30 (or more) at the start of the script, or use a systemd unit with After=network-online.target.