Run a Cron Job at Reboot With @reboot
Put @reboot /path/to/script in your crontab to run a command once each time the machine boots. It runs when cron itself starts, not on every reconnect.
The directive
@reboot is a special cron string that runs the job a single time when the cron daemon starts at boot. Example line: @reboot /home/user/startup.sh.
When it actually fires
It fires when cron starts, which is early in boot. If you need the network or a database up first, add a delay: @reboot sleep 30 && /home/user/startup.sh.
Not supported everywhere
systemd timers and some minimal cron builds do not support @reboot. On systemd, use a service with WantedBy=multi-user.target instead.
FAQ
What does @reboot do in cron?
@reboot runs the command once when the cron daemon starts at system boot, rather than on a time schedule.
How do I delay a @reboot job?
Prefix a sleep: @reboot sleep 30 && /path/to/script.sh waits 30 seconds for services to come up.
Does systemd support @reboot?
No. Use a systemd service unit with WantedBy=multi-user.target, or a timer with OnBootSec=.