Thursday, March 31, 2016

How to create CRONTAB to restart ubuntu





Use cron (should already be installed):

Edit crontab:
sudo crontab -e

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

Insert a line like
0 6   *   *   *    /sbin/shutdown -r +5
at the bottom. Explanation:
m      h    dom        mon   dow       command
minute hour dayOfMonth Month dayOfWeek commandToRun
so the line
  0 6   *   *   *    /sbin/shutdown -r +5

would reboot your system every day at 6:05am. (6:00am + 5 minutes)

Ctrl+X, Y, Enter should get you out of crontab (if using nano)

Note: you might have to run crontab -e as root, because shutdown needs root.

No comments: