The server in the project needs to be scheduled to automatically restart the server function, the same is also the use of crontab command.
Generally our servers are installed by default, the direct execution of the second step can be, but some distributions are not installed, so we no matter how to install the first, if installed or not installed, it does not matter.
The code is as follows |
Copy Code |
Yum Install Vixie-cron Crontabs
Chkconfig Crond on
Service Crond Start
|
The code is as follows |
Copy Code |
Apt-get Install cron
/etc/init.d/cron restart
|
This is based on our server environment, then installs the crontab, and starts.
Second, edit timed automatic script
The code is as follows |
Copy Code |
Crontab-e
|
Execute the script in SSH and edit the file.
The code is as follows |
Copy Code |
0 1 * * */sbin/reboot
|
Throw in this script, which means restarting the server 1 o'clock in the morning every day. After editing: Wq save exit.
Third, save exit restart effective
The code is as follows |
Copy Code |
/etc/rc.d/init.d/crond stop
/etc/rc.d/init.d/crond start
|
This can be done after the implementation, you can achieve the time we need to automatically restart the server function. In fact, the friend said that the need to log in to the background restart is not correct, we can directly login ssh, and then perform reboot restart, there is no need for you to log in to the website background click on his restart button.