適用于 centos7 和ubuntu16.04+的快捷設(shè)置方法。
查看時間時區(qū)
通過一個命令:timedatectl 查看時間和時區(qū)和NTP是否同步等信息一目了然,非常好用。
root@tos-cen084036:~# timedatectl
Local time: Fri 2018-04-27 21:56:17 CST
Universal time: Fri 2018-04-27 13:56:17 UTC
RTC time: Fri 2018-04-27 13:57:11
Time zone: Asia/Shanghai (CST, +0800)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
時間同步設(shè)置
設(shè)置時區(qū)
如果你的時區(qū)不對,用下面的命令設(shè)置
timedatectl set-timezone Asia/Shanghai
時間同步服務(wù)神器chrony
安裝
yum/apt install chrony
設(shè)置開機(jī)啟動
systemctl enable chronyd
啟動chronyd
systemctl restart chronyd
查看chrony 效果
root@tos-cen084036:~# chronyc sources -v
210 Number of sources = 4
.-- Source mode '^' = server, '=' = peer,'#' = local clock.
/ .- Source state '*' = current synced, '+'= combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be inerror, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx= adjusted offset,
|| Log2(Polling interval) --. | | yyyy =measured offset,
|| | | zzzz = estimated error.
|| | |
MS Name/IP address Stratum Poll ReachLastRx Last sample
===============================================================================
^- 61-216-153-105.hinet-ip.h 3 8 266 529+24ms[ +25ms] +/- 92ms
^- 119.79-161-57.customer.ly 2 10 375 955+31ms[ +32ms] +/- 305ms
^* time4.aliyun.com 2 9 377 258 +12ms[+14ms] +/- 20ms
^- ntp5.flashdance.cx 2 9 267 109 +17ms[+17ms] +/- 137ms
結(jié)束語
用戶會說那設(shè)置完怎樣使Linux繼續(xù)保持精準(zhǔn)的NTP同步時間信息,根據(jù)教程這樣簡單的設(shè)置下,再也不用擔(dān)心,服務(wù)器的時間不準(zhǔn)了。
咨詢電話:
掃一掃咨詢微信客服