The setting method of Centos/debian environment automatic timing restart for Linux server

Source: Internet
Author: User
Tags ssh centos
The server in the project needs to be scheduled to automatically restart the server function, the same is also the use of crontab command.

First, install Crontab

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.

1, CentOS

The code is as follows Copy Code

Yum Install Vixie-cron Crontabs
Chkconfig Crond on
Service Crond Start

2. Debian

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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.