[root@server-2 ~]# yum install -y ntpdate
// 方式一、使用域名连接,要经过DNS解析,速度慢。 [root@server-2 ~]# ntpdate pool.ntp.org // 方式二、使用IP连接,超级快。 [root@server-2 ~]# ntpdate 120.24.81.91
http://www.pool.ntp.org is the official website of NTP. On this we can find the NTP Server cn.pool.ntp.org from our country. It has 3 server addresses:
Server 1: 1.cn.pool.ntp.org
Server two: 2.asia.pool.ntp.org
Server three: 3.asia.pool.ntp.org
(There are sometimes problems with using domain names directly. You can ping their IP first and then synchronize it with the IP address)
// The following message appears to indicate success
Feb 21:23:06 ntpdate[62910]: step time server 182.92.12.11 offset -40.589470 sec
//Display hardwareclock system hardware time
[root@server-2 ~]# hwclock
//Write the system time into the system hardware
[root@server-2 ~]# hwclock -w
The crontab format is as follows:
# For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * command to be executed
Code:
11 * * * root ntpdate 210.72.145.44
Synchronize time with China National Time Service Center at 11 o'clock every day
Synchronize time with China National Time Service Center at 11 o'clock every day
Of course the premise is
apt-get install ntpdate
Code is also available
11 * * * root ntpdate us.pool.ntp.org
crontab -e 10 5 * * * root ntpdate us.pool.ntp.org;hwclock -w
In this way, the network time will be automatically adjusted at 5:10 every day, and the BIOS time will be updated at the same time
The above is the detailed content of How to synchronize time with the Internet under Linux. For more information, please follow other related articles on the PHP Chinese website!