Simple steps to synchronize CentOS time


When using CentOS system, we may encounter the problem of inaccurate time. How can we solve this problem? Let’s teach you a method of time synchronization in CentOS system. I hope you can solve your own problems.

The steps of time synchronization in CentOS system are as follows:

The newly installed CentOS system server may have set the wrong time zone and time

Here is the CentOS system using NTP to synchronize from a time server
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

It’s very simple!

The first sentence is to adjust the current time zone to Shanghai, which is + 8. If you want to change other time zones, you can also go to the / usr / share / zoneinfo directory;

Then the second sentence is to use ntpdate to synchronize the standard time

If ntpdate is not installed, you can:
yum install -y ntpdate

Join the scheduled task and synchronize the clock every 10 minutes
crontab -e
0-59/10 * * * * /usr/sbin/ntpdate | logger -t NTP

In this way, we can solve the problem of inaccurate time in CentOS system.