For Linux users, it is always easy to find the solution of operations you’re confused about. Similarly, if you want to reboot the system, you don’t need to install any specific tool or package.
Some of the processes also require rebooting the system for the configurational changes. It is good to reboot the system when needed, but doing it daily could create problems. So be careful!
The Crontab, or we can call cron table, is the built-in Linux utility that helps to schedule the processes and execute them at the specified time. The Cron table consists of predefined scripts and commands from where the Cron daemon reads them. The Cron allows the user to configure the predefined commands in the Cron table and set them to run automatically.
Some tasks need to perform daily, while some weekly, and similarly monthly and yearly.
Follow the guide if you want to schedule a reboot daily on the system:
How to Schedule Reboot Daily using Crontab
Following is the format of Crontab:
Fields | Allowed Value |
---|---|
MIN (minutes) | 0 – 59 |
HOUR (hour field) | 0 – 23 |
DOM (day of month) | 1 – 31 |
MON (month field) | 1 – 12 |
DOW (day of the week) | 0 – 6 |
CMD (command) | Command to be executed |
Open a terminal and type the mentioned command to get /etc/crontab file:
The file will look like this:
You can also get it using the command:
(You will be asked to select a preferable editor such as vim, nano, etc. for crontab file)
Scroll down the file and write the mentioned line at the end of it:
The above line will force the system to restart daily at 10 a.m.
Note that: The shutdown –r command is used to restart the system.
Conclusion
The writeup has shown how to reboot the system daily. You can do it by typing the shutdown -r command regularly on the terminal. However, to avoid writing the shutdown command daily, you can do it through Crontab.
The Crontab utility helps to schedule processes and execute them on time. All the predefined commands are written in the Cron table from where Cron daemon reads them. To schedule a process, you can edit the /etc/crontab file and set timings according to the requirement.