Automatic date and time synchronization setting in CentOS
There are at least two methods to synchronize time in linux:
Rdate and ntpdate. Centos installation is not installed by default. Check whether it has been installed. Otherwise, install it first.
WhereRdate is used to obtain the time on the remote time server. With the-s parameter, you can apply the obtained time to the local system.
NAME rdate - get the time via the networkSYNOPSIS rdate [-p] [-s] [-u] [-l] [-t sec] [host...]DESCRIPTION rdate connects to an RFC 868 time server over a TCP/IP network, printing the returned time and/or setting the system clock. OPTIONS -p Print the time returned by the remote machine. -s Set the system time to the returned time. -u Use UDP instead of TCP as the transport. -l Use syslog to output errors (cron.warning) and output (cron.info). -t Set timeout in seconds for every attempt to retreive date.
Rdate-s time.nist.gov
Ntpdate is a tool used to synchronize time.
Example: ntpdate ntp.sjtu.edu.cn
NAME ntpdate-set the date and time via NTP Disclaimer: The functionality of this program is now available in the ntpd program. see the-q com-mand line option in the ntpd-Network Time Protocol (NTP) daemon page. after a suitable period of mourning, the ntpdate program is to be retired from this distributionSYNOPSIS ntpdate [-46 bBdqsuv] [-a key] [-e authdelay] [-k keyfile] [-o version] [-p samples] [-t timeout] [-U user_name] server [...] DESCRIPTION [omitted. For details, refer to the linux man manual]
Date and Time ServerThe synchronization time must have a time server. Generally, we do not need to build our own services. We can use public time services.
Refer to the domestic NTP server address and IP address http://www.douban.com/note/171309770/
The National Time Service Center does not seem to be available. We recommend that you use the ntp service ntp.sjtu.edu.cn or the United States Time Service Center time.nist.gov.
On the code, copy it to use
Rdate-s time.nist.gov
Ntpdate ntp.sjtu.edu.cn
It can be added to the crontab for scheduled execution.