After installing updates it may needed reboot. Rebooting systems in office hours is a bad thing to happen. What can we do? We can set Linux system to restart after office hours with automated reboot. There are two ways to auto reboot. We will look both of them.
Using At Command
We can use
at command to specify boot time. We can do different things with
at like sending emails etc.
Now we want to restart 12:43
$ at 12:43
at provides shell to enter command. To exit from shell use CTRL+D .
- 12:43 is the time we want to run command
- reboot is the command we want to run
List At Jobs
We may want to list allready setup jobs with atq
2 Tue Nov 15 20:00:00 2016 a root
Remove Pending Jobs
We can remove pending jobs with atrm command.
$ atrm 2
- 2 is the id of the pending job which can be find with atq command
Run After 5 Minutes
$ at now + 5 minutes
Run 6 A.M. Monday
$ at 6am
Run 01 A.M. July 21
$ at 1am Jul 21
Cron is a service to run commands scripts at specified time.
Open Cron Table
To add timed task we will open cron table to add entry.
Open Cron Table With Specified User
By default cron table is opened for current user so added command will run for this user. We can specify user to run command like below
crontab -e -u ismail
Add Entry Cron Table
We will add new entry to the cron table
20 * * * /sbin/shutdown
This will shutdown our system every day at 20:00