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