How can I schedule a nightly reboot?

crontab

I’d use cron (should already be installed):

sudo crontab -e

The first time you might have to choose your preferred editor (like nano)

Insert a line like

0 4   *   *   *    /sbin/shutdown -r +5

at the bottom. Explanation:

m      h    dom        mon   dow       command
minute hour dayOfMonth Month dayOfWeek commandToRun

would announce the reboot every day at 4:00am, then reboot 5 minutes later (at 4:05am).

Ctrl+XYEnter should get you out of crontab (if using nano)

Note: you might have to run crontab -e as root, because shutdown needs root. crontab -e opens a file in /tmp instead of the actual crontab so that it can check your new crontab for errors. If there are no errors, then your actual crontab will be updated.

Comments

Leave a Reply

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