Automatic date and time synchronization setting in CentOS

Source: Internet
Author: User
Automatic date and time synchronization in centos (rdate and ntpdate)

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.

WhereRdateIt is used to obtain the time on the remote time server. with the-s parameter, the obtained time can be applied 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

NtpdateIt 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 server

The 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.

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.