Linux Synchronization Network Time

Source: Internet
Author: User

How to synchronize Linux time with Internet time (CentOS) article content source: http://www.cnblogs.com/itxiongwei/p/5556558.html

When I use Linux (virtual machine), I often find that after a period of time, Linux time and my host (real machine) time is not consistent, and the host time is really Internet time, install Linux when the time zone selected is also Asia/shanghai, So what I'm sharing today is how to keep Linux time in sync with Internet time.

Before we solve the problem, let's start by understanding the following points of knowledge:

1. Date command:

#date

Show System time

2.hwclock command (i.e. Hardwareclock system hardware time)

#hwclock

Show Hardware Time

#hwclock-W

Write system time to system hardware

3.ntpdate

Ntpdate is a Linux time synchronization service software, detailed information please refer to the following Baidu, there are a lot of detailed information

Second, check whether this machine installs Ntpdate service, if not installed, please yum install-y ntpdate

Third, synchronization time

1. Enter ntpdate time.nist.gov Sync Network time

Results: 3 June 15:42:39 ntpdate[4721]: Adjust time server 211.115.194.21 offset-0.005885 sec

The above results indicate that the time synchronization is successful, the above meaning is the time to adjust the time for the server 211.115.194.21, the time difference-0.005885 seconds

If the above time.nist.gov server is not synchronized, you can change the following several times the server to try:
Time.nist.gov
Time.nuri.net
0.asia.pool.ntp.org
1.asia.pool.ntp.org
2.asia.pool.ntp.org
3.asia.pool.ntp.org

2. Adjust the hardware time after the synchronization time is successful

#hwclock-W

After successful execution, check the system hardware time (not surprisingly, now date and Hwclock reality time are Internet time)

#date

#hwclock

Execute the above command, it should show the same time

Four, timed time synchronization tasks, so we use CRONTAB-E to add timed tasks

#* */1 * * * Root ntpdatetime.nuri.net;hwclock-w

That is, synchronize Internet time every one hours.

Linux Synchronization Network Time

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.