How to automatically restart a server daily or a particular interval?

A server can be scheduled to restart at a particular time using crontab.

Here are the steps:,

#1. Switch to the root user
#2. Enter crontab in edit mode:
Code:
ubuntu@aws-ubuntu:~$ sudo su -
root@aws-ubuntu:~#
root@aws-ubuntu:~# crontab -e

#3. Add the below, schedule to the crontab:
Code:
15 3 * * * /sbin/shutdown -r now > /var/log/coron-restart.log 2>&1

You may change the time and frequency in the crontab.

Please take care of your application restart as well if you have applications running, such as a database or webserver.

Let us know if you have any questions?