在Windwos中,系统时间的设置很简单,界面操做,通俗易懂。并且设置后,重启,关机都不要紧。系统时间会自动保存在Bios的时钟里面,启动计算机的时候,系统会自动在Bios里面取硬件时间,以保证时间的不间断。html
但在Linux下,默认状况下,系统时间和硬件时间,并不会自动同步。在Linux运行过程当中,系统时间和硬件时间以异步的方式运行,互不干扰。硬件时间的运行,是靠Bios电池来维持,而系统时间,是用CPU tick来维持的。linux
在系统开机的时候,会自动从Bios中取得硬件时间,设置为系统时间。ios
一.Linux系统时间的设置数据库
在Linux中设置系统时间,能够用date命令:安全
//查看时间服务器
[root@localhost ~]# date
2008年 12月 12日星期五 14:44:12 CST网络
//修改时间
[root@localhost ~]# date -set "2013-12-24 00:01" <== (年/月/日 时:分【:秒】)
2009年 01月 01日星期四 00:01:00 CSTapp
//date 有几种时间格式可接受,这样也能够设置时间:less
[root@localhost ~]# date 012501012009.30 <== 月日时分年.秒
2009年 01月 25日星期日 01:01:30 CST异步
二.Linux硬件时间的设置
硬件时间的设置,能够用hwclock或者clock命令。其中,clock和hwclock用法相近,只用一个就行,只不过clock命令除了支持x86硬件体系外,还支持Alpha硬件体系。
//查看硬件时间能够是用hwclock,hwclock --show 或者hwclock -r
[root@localhost ~]# hwclock --show
2008年12月12日星期五 06时52分07秒 -0.376932 seconds
//设置硬件时间
[root@localhost ~]# hwclock --set --date="1/25/09 00:00" <== 月/日/年时:分:秒
[root@localhost ~]# hwclock
2009年01月25日星期日 00时00分06秒 -0.870868 seconds
[root@localhost ~]# hwclock -w 根据系统时间设置硬件时间
三.系统时间和硬件时间的同步
同步系统时间和硬件时间,可使用hwclock命令。
//以系统时间为基准,修改硬件时间
[root@localhost ~]# hwclock --systohc<== sys(系统时间)to(写到)hc(Hard Clock)
[root@localhost ~]# hwclock -w
//以硬件时间为基准,修改系统时间
[root@localhost ~]# hwclock --hctosys
[root@localhost ~]# hwclock -s
四.不一样机器之间的时间同步(重点)
为了不主机时间由于长期运做下所致使的时间误差,进行时间同步(synchronize)的工做是很是必要的。Linux系统下,通常使用ntp服务器来同步不一样机器的时间。一台机器,能够同时是ntp服务器和ntp客户机。在网络中,推荐使用像DNS服务器同样分层的时间服务器来同步时间。
同步时间,可使用ntpdate命令,也可使用ntpd服务(debian中ntp服务器为ntp服务,须要安装apt-get install ntp,同时对上手动同步时间须要用到ntpdate,故还需安装apt-get install ntpdate)。
使用ntpdate比较简单。格式以下:
[root@linux ~]# ntpdate [-nv] [NTP IP/hostname]
[root@linux ~]# ntpdate 192.168.0.2
[root@linux ~]# ntpdate time.ntp.org
但这样的同步,只是强制性的将系统时间设置为ntp服务器时间。若是cpu tick有问题,只是治标不治本。因此,通常配合cron命令,来进行按期同步设置。好比,在crontab中添加:
0 12 * * * * /usr/sbin/ntpdate 192.168.0.1
这样,会在天天的12点整,同步一次时间。ntp服务器为192.168.0.1。
使用ntpd服务,要好于ntpdate加cron的组合。由于,ntpdate同步时间,会形成时间的跳跃,对一些依赖时间的程序和服务会形成影响。好比sleep,timer等。并且,ntpd服务能够在修正时间的同时,修正cpu tick。理想的作法为,在开机的时候,使用ntpdate强制同步时间,在其余时候使用ntpd服务来同步时间。
要注意的是,ntpd有一个自我保护设置: 若是本机与上源时间相差太大, ntpd不运行. 因此新设置的时间服务器必定要先ntpdate从上源取得时间初值, 而后启动ntpd服务。ntpd服务运行后, 先是每64秒与上源服务器同步一次, 根据每次同步时测得的偏差值经复杂计算逐步调整本身的时间, 随着偏差减少, 逐步增长同步的间隔. 每次跳动, 都会重复这个调整的过程.
五.ntpd服务的设置
ntpd服务的相关设置文件以下:
1./etc/ntp.conf:这个是NTP daemon的主要设文件,也是 NTP 惟一的设定文件。
2./usr /share/zoneinfo/:在这个目录下的文件实际上是规定了各主要时区的时间设定文件,例如北京地区的时区设定文件在/usr/share/zoneinfo/Asia/Beijing 就是了。这个目录里面的文件与底下要谈的两个文件(clock 与localtime)是有关系的。
3./etc/sysconfig/clock:这个文件其实也不包含在NTP 的 daemon 当中,由于这个是linux的主要时区设定文件。每次开机后,Linux 会自动的读取这个文件来设定本身系统所默认要显示的时间。
4./etc /localtime:这个文件就是“本地端的时间配置文件”。刚刚那个clock 文件里面规定了使用的时间设置文件(ZONE) 为/usr/share/zoneinfo/Asia/Beijing ,因此说,这就是本地端的时间了,此时, Linux系统就会将Beijing那个文件另存为一份/etc/localtime文件,因此将来咱们的时间显示就会以Beijing那个时间设定文件为准。
5. /etc/timezone:系统时区文件
下面重点说说 /etc/ntp.conf文件的设置。在 NTP Server 的设定上面,其实最好不要对 Internet 无限制的开放,尽可能仅提供您本身内部的 Client 端联机进行网络校时就好。此外, NTP Server 总也是须要网络上面较为准确的主机来自行更新本身的时间啊,因此在咱们的 NTP Server 上面也要找一部最靠近本身的 Time Server 来进行自我校订。事实上, NTP 这个服务也是Server/Client 的一种模式。
[root@linux ~]# vi /etc/ntp.conf
# 1. 关于权限设定部分
# 权限的设定主要以 restrict 这个参数来设定,主要的语法为:
# restrict IP mask netmask_IP parameter
# 其中 IP 能够是软件地址,也能够是 default ,default 就相似 0.0.0.0
# 至于paramter则有:
# ignore :关闭全部的 NTP 联机服务
# nomodify:表示 Client 端不能更改 Server 端的时间参数,不过,
# Client 端仍然能够透过 Server 端来进行网络校时。
# notrust:该 Client 除非经过认证,不然该 Client 来源将被视为不信任网域
# noquery:不提供 Client 端的时间查询
# notrap:不提供trap这个远程事件登入
# 若是paramter彻底没有设定,那就表示该 IP (或网域)“没有任何限制”
restrict default nomodifynotrapnoquery # 关闭全部的 NTP 要求封包
restrict 127.0.0.1 #这是容许本级查询
restrict 192.168.0.1 mask 255.255.255.0 nomodify
#在192.168.0.1/24网段内的服务器就能够经过这台NTP Server进行时间同步了
# 2. 上层主机的设定
# 要设定上层主机主要以 server 这个参数来设定,语法为:
# server [IP|HOST Name] [prefer]
# Server 后面接的就是咱们上层 Time Server 啰!而若是 Server 参数
# 后面加上perfer的话,那表示咱们的 NTP 主机主要以该部主机来做为
# 时间校订的对应。另外,为了解决更新时间封包的传送延迟动做,
# 因此可使用driftfile来规定咱们的主机
# 在与 Time Server 沟通时所花费的时间,能够记录在driftfile
# 后面接的文件内,例以下面的范例中,咱们的 NTP server 与
# cn.pool.ntp.org联机时所花费的时间会记录在 /etc/ntp/drift文件内
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server cn.pool.ntp.org prefer
#其余设置值,以系统默认值便可
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
broadcastdelay 0.008
keys /etc/ntp/keys
总结一下,restrict用来设置访问权限,server用来设置上层时间服务器,driftfile用来设置保存漂移时间的文件。
六.ntp服务的启动与观察
在启动NTP服务前,先对提供服务的这台主机手动的校订一次时间咯。(由于启动服务器,端口会被服务端占用,就不能手动同步时间了)
[root@linux ~] # ntpdate cn.pool.ntp.org
25 Apr 14:33:51 ntpdate[8310]: step time server 80.85.129.2 offset 6.655976 sec
而后,启动ntpd服务:
[root@linux ~] # service ntpd start
或 [root@linux ~] # /etc/init.d/ntpd start
查看端口:
[root@linux ~] # netstat -ln|grep 123
udp 0 0 192.168.228.153:123 0.0.0.0:*
udp 0 0 127.0.0.1:123 0.0.0.0:*
udp 0 0 0.0.0.0:123 0.0.0.0:*
udp 0 0 :::123 :::*
如何确认咱们的NTP服务器已经更新了本身的时间呢?
[root@linux ~] # ntpstat
synchronized to NTP server(127.127.1.0) at stratum 11
time correct to within 950ms
polling server every 64 s
#改指令可列出NTP服务器是否与上层联机。由上述输出结果可知,时间校订约
#为950*10(-6)秒。且每隔64秒会主动更新时间。
常见的错误:
25 Apr 15:30:17 ntpdate[11520]: no server suitable for synchronization found
其实,这不是一个错误。而是因为每次重启NTP服务器以后大约要3-5分钟客户端才能与server创建正常的通信链接。当此时用客户端链接服务端就会报这样的信息。通常等待几分钟就能够了。
[root@linux ~] # ntptrace –n 127.0.0.1
127.0.0.1:stratum 11, offset 0.000000,synch distance 0.950951
222.73.214.125:stratum 2,offset –0.000787,synch distance 0.108575
209.81.9.7:stratum 1,offset 0.000028,synch distance 0.00436,refid ‘GPS’
#这个指令能够列出目前NTP服务器(第一层)与上层NTP服务器(第二层)彼此之间的
#关系
[root@linux ~] # ntpq –p
指令“ntpq -p”能够列出目前咱们的NTP与相关的上层NTP的状态,以上的几个字段的意义以下:
remote:即NTP主机的IP或主机名称。注意最左边的符号,若是由“+”则表明目前正在做用钟的上层NTP,若是是“*”则表示也有连上线,不过是做为次要联机的NTP主机。
refid:参考的上一层NTP主机的地址
st:即stratum阶层
when:几秒前曾作过期间同步更新的操做
poll:下次更新在几秒以后
reach:已经向上层NTP服务器要求更新的次数
delay:网络传输过程钟延迟的时间
offset:时间补偿的结果
jitter:Linux系统时间与BIOS硬件时间的差别时间
最后说起一点,ntp服务,默认只会同步系统时间。若是想要让ntp同时同步硬件时间,能够设置/etc/sysconfig/ntpd文件。
在/etc/sysconfig/ntpd文件中,添加 SYNC_HWCLOCK=yes 这样,就可让硬件时间与系统时间一块儿同步。
转自:http://blog.sina.com.cn/s/blog_636a55070101u1mg.html
其它:
NTP的配置
A: 配置/etc/ntp.conf
NTP Server的主要配置文件为/etc/ntp.conf ,没有修改过的ntp.conf文件内容以下所示,配置选项都有相关注释信息(Linux 版本为Red Hat Enterprise Linux Server release 6.6 )
[root@localhost ~]# more /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# Enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
各个选项信息:
#系统时间与BIOS事件的误差记录
driftfile /etc/ntp/drift
restrict 控制相关权限。
语法为: restrict IP地址 mask 子网掩码 参数
其中IP地址也能够是default ,default 就是指全部的IP
参数有如下几个:
ignore :关闭全部的 NTP 联机服务
nomodify:客户端不能更改服务端的时间参数,可是客户端能够经过服务端进行网络校时。
notrust :客户端除非经过认证,不然该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询:用户端不能使用ntpq,ntpc等命令来查询ntp服务器
notrap :不提供trap远端登录:拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq 控制消息协议的子系统,用于远程事件日志记录程序。
nopeer :用于阻止主机尝试与服务器对等,并容许欺诈性服务器控制时钟
kod : 访问违规时发送 KoD 包。
restrict -6 表示IPV6地址的权限设置。
1:设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,因此优先指定从该主机同步时间。
server 192.168.7.49 prefer
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
2:限制你容许的这些服务器的访问类型,在这个例子中的服务器是不允许修改运行时配置或查询您的Linux NTP服务器
restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap
在上例中,掩码地址扩展为255,所以从192.168.0.1-192.168.0.254的服务器均可以使用咱们的NTP服务器来同步时间
#此时表示限制向从192.168.0.1-192.168.0.254这些IP段的服务器提供NTP服务。
restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap noquery
#设置默认策略为容许任何主机进行时间同步
restrict default ignore
3:确保localhost(这个经常使用的IP地址用来指Linux服务器自己)有足够权限.使用没有任何限制关键词的语法:
restrict 127.0.0.1
restrict -6 ::1
B:配置/etc/ntp/stpe-tickers文件
修改/etc/ntp/stpe-tickers文件,内容以下(当ntpd服务启动时,会自动与该文件中记录的上层NTP服务进行时间校对)
[root@localhost ntp]# more /etc/ntp/step-tickers
# List of servers used for initial synchronization.
[root@localhost ntp]# vi /etc/ntp/step-tickers
# List of servers used for initial synchronization.
server 192.168.7.49 prefer
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
server 3.rhel.pool.ntp.org
关于ntp.conf and step-tickers区别:
step-tickers is used by ntpdate where as ntp.conf is the configuration file for the ntpd daemon. ntpdate is initially run to set the clock before ntpd to make sure time is within 1000 sec. ntp will not run if the time difference between the server and client by more then 1000 sec ( or there about). The start up script will read step-tickers for servers to be polled by ntpdate.
C:配置/etc/sysconfig/ntpd文件
ntp服务,默认只会同步系统时间。若是想要让ntp同时同步硬件时间,能够设置/etc/sysconfig/ntpd文件,在/etc/sysconfig/ntpd文件中,添加 SYNC_HWCLOCK=yes 这样,就可让硬件时间与系统时间一块儿同步。
#容许BIOS与系统时间同步,也能够经过hwclock -w 命令
SYNC_HWCLOCK=yes
IPTABLES 配置
因为NTP服务须要使用到UDP端口号123,因此当系统的防火墙(Iptables)启动的状况下,必须开放UDP端口号123。
[root@localhost ~]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
[root@localhost ~]# /sbin/iptables -I INPUT -p udp --dport 123 -j ACCEPT
[root@localhost ~]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:123
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
[root@localhost ~]#
若是防火墙没有开放UDP端口号123,有可能出现下面状况。
[root@localhost ~]# /usr/sbin/ntpq -c rv | grep stratum
stratum=16, precision=-24, rootdelay=0.000, rootdisp=3.525, refid=INIT,
[root@localhost~]#
A stratum level of 16 indicates that NTP is not synchronizing correctly.If a stratum level of 16 is detected, wait 15 minutes and issue the command again. It may take this long for the NTP server to stabilize.If NTP continues to detect a stratum level of 16, verify that the NTP port (UDP Port 123) is open on all firewalls between the cluster and the remote machine you are attempting to synchronize to.
启动NTP服务
[root@localhost ~]# service ntpd status
ntpd is stopped
[root@localhost ~]# service ntpd start
Starting ntpd: [ OK ]
[root@localhost ~]#
service ntpd status #查看ntpd服务状态
service ntpd start #启动ntpd服务
service ntpd stop #中止ntpd服务
service ntpd restart #重启ntpd服务
检查ntp服务是否开机启动,将其设置为开机启动。
[root@localhost ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost ~]# runlevel
N 3
[root@localhost ~]# chkconfig ntpd on #在运行级别二、三、四、5上设置为自动运行
[root@localhost ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]#
若是要设置在运行级别上自动运行,可使用下面命令
chkconfig --level 345 ntpd on
能够用下面命令检测NTP服务是否运行
[root@localhost ~]# pgrep ntpd
2639
2641
[root@localhost ~]# netstat -tlunp | grep ntp #若是看到123端口,说明ntp服务成功启动。
udp 0 0 192.168.7.224:123 0.0.0.0:* 2639/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 2639/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 2639/ntpd
udp 0 0 fe80::250:56ff:feb3:b5:123 :::* 2639/ntpd
udp 0 0 ::1:123 :::* 2639/ntpd
udp 0 0 :::123 :::* 2639/ntpd
[root@localhost ~]#
查看ntp服务器有无和上层ntp连通
[root@localhost ~]# ntpstat
synchronised to NTP server (192.168.7.49) at stratum 6
time correct to within 440 ms
polling server every 128 s
[root@localhost ~]#
查看ntp服务器与上层ntp的状态
[root@localhost ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.7.49 192.168.7.50 5 u 13 64 3 5.853 1137178 2.696
[root@localhost ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.7.49 192.168.7.50 5 u 17 64 3 5.853 1137178 2.696
[root@localhost ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.7.49 192.168.7.50 5 u 1 64 1 0.937 -9.570 0.000
remote - 本机和上层ntp的ip或主机名,“+”表示优先,“*”表示次优先
refid - 参考上一层ntp主机地址
st - stratum阶层
when - 多少秒前曾经同步过期间
poll - 下次更新在多少秒后
reach - 已经向上层ntp服务器要求更新的次数
delay - 网络延迟
offset - 时间补偿
jitter - 系统时间与bios时间差
要查看 ntpd 进程的状态,请运行如下命令,按 Ctrl+C 中止查看进程。
第一列中的字符指示源的质量。星号 ( * ) 表示该源是当前引用。
remote 列出源的 IP 地址或主机名。
when 指出从轮询源开始已过去的时间(秒)。
poll 指出轮询间隔时间。该值会根据本地时钟的精度相应增长。
reach 是一个八进制数字,指出源的可存取性。值 377 表示源已应答了前八个连续轮询。
offset 是源时钟与本地时钟的时间差(毫秒)。
ntpd、ntpdate的区别
下面是网上关于ntpd与ntpdate区别的相关资料。以下所示所示:
使用以前得弄清楚一个问题,ntpd与ntpdate在更新时间时有什么区别。ntpd不只仅是时间同步服务器,它还能够作客户端与标准时间服务器进行同步时间,并且是平滑同步,并不是ntpdate当即同步,在生产环境中慎用ntpdate,也正如此二者不可同时运行。
时钟的跃变,对于某些程序会致使很严重的问题。许多应用程序依赖连续的时钟——毕竟,这是一项常见的假定,即,取得的时间是线性的,一些操做,例如数据库事务,一般会地依赖这样的事实:时间不会往回跳跃。不幸的是,ntpdate调整时间的方式就是咱们所说的”跃变“:在得到一个时间以后,ntpdate使用settimeofday(2)设置系统时间,这有几个很是明显的问题:
第一,这样作不安全。ntpdate的设置依赖于ntp服务器的安全性,攻击者能够利用一些软件设计上的缺陷,拿下ntp服务器并令与其同步的服务器执行某些消耗性的任务。因为ntpdate采用的方式是跳变,跟随它的服务器没法知道是否发生了异常(时间不同的时候,惟一的办法是以服务器为准)。
第二,这样作不精确。一旦ntp服务器宕机,跟随它的服务器也就会没法同步时间。与此不一样,ntpd不只可以校准计算机的时间,并且可以校准计算机的时钟。
第三,这样作不够优雅。因为是跳变,而不是使时间变快或变慢,依赖时序的程序会出错(例如,若是ntpdate发现你的时间快了,则可能会经历两个相同的时刻,对某些应用而言,这是致命的)。于是,惟一一个能够令时间发生跳变的点,是计算机刚刚启动,但尚未启动不少服务的那个时候。其他的时候,理想的作法是使用ntpd来校准时钟,而不是调整计算机时钟上的时间。
NTPD 在和时间服务器的同步过程当中,会把 BIOS 计时器的振荡频率误差——或者说 Local Clock 的天然漂移(drift)——记录下来。这样即便网络有问题,本机仍然能维持一个至关精确的走时。
转自:https://www.cnblogs.com/kerrycode/archive/2015/08/20/4744804.html