Cron Tip: Reboot Jobs

If you have an account at a managed hosting service (shared hosting, VPS, etc), system reboots can be unexpected and confusing events. Sysadmins need to reboot for a variety of reasons — hardware problems, security patches, vandalism — and they rarely inform users before or even after the reboot. All you might see are some confusing messages in your error logs, or gaps in the traffic logs.

One solution is to setup a reboot job in your cron table, like this:

@reboot         echo 'Uh oh, a Reboot!'

Now, every time the system is rebooted you will get an email, and you will be better able to interpret or fix any problems that show up.

One caveat is that @reboot jobs are run whenever the cron daemon starts, so false positives are possible. However, in practice the cron daemon is almost never restarted on its own.

1 thought on “Cron Tip: Reboot Jobs

  1. Thanks! This will help a lot. I had a hardware-driven reboot happen today, and it took a while to figure out what happened.

Leave a Reply

Your email address will not be published. Required fields are marked *