Friday, August 26, 2016

Daily reboot (debian/ubuntu/etc)

If you want to reboot your linux box daily you can use cron and shutdown or reboot commands.

First login as root then:
crontab -e
Add line (command will run at 2:05 am and it will give warning about reboot to all users and reboot in 10 minutes):
5 2 * * * /sbin/shutdown -r +10 
Crontab command explanations (http://www.adminschoice.com/crontab-quick-reference): 
*     *     *   *    *        command to be executed
-     -     -   -    -
|     |     |   |    |
|     |     |   |    +----- day of week (0 - 6) (Sunday=0)
|     |     |   +------- month (1 - 12)
|     |     +--------- day of        month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59) 
If you have other location for shutdown command, you can search it with:
find / -name shutdown
Also if you have problems with shutdown-command you can try using reboot-command.

No comments:

Post a Comment