CentOS/Linux automatically synchronize server time

The newly installed CentOS system server may set the wrong time. When doing a cluster, the time is very important. It is very likely that the cluster will fail due to the time. Therefore, you need to adjust the time zone and adjust the time. The following is the CentOS system using NTP to synchronize the time from a time server, so that the time is synchronized once.

NTP: Short for Network Time Protocol, the Network Time Protocol, is a standard Internet protocol used for time synchronization in the Internet. The purpose of NTP is to synchronize the computer's time to a certain time standard. The current time standard is UTC (Universal Time Coordinated).

The steps of CentOS system time synchronization are as follows:

1. Download ntpdate
Note: Some versions do not come with ntpdate, so you need to download
# yum install -y ntpdate

2. Adjust the time zone to Shanghai, that is, Beijing time + 8 zone
Note: If you want to change other time zones, you can also go to the /usr/share/zoneinfo directory
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# yes | cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

3. Use NTP to synchronize time
# ntpdate us.pool.ntp.org

4. Timing synchronization time (clock synchronization every 10 minutes)
# crontab -l >/tmp/crontab.bak
# echo "*/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger - t NTP" >> /tmp/crontab.bak
# crontab /tmp/crontab.bak

This way we solve the timing problem.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327086923&siteId=291194637