chronyd

本文介绍了Chrony的时间同步工具,如何配置NTP服务器,限制系统时钟调整,以及使用命令行进行时间同步、查看同步状态和BIOS时间设置。默认情况下,Chrony渐进式调整时钟,但在特殊情况下允许快速步进。
摘要由CSDN通过智能技术生成
chronyd

https://chrony-project.org/doc/4.1/chrony.conf.html

无时钟源配置可参考 : Isolated networks

通过互联网同步的两台机器之间的典型精度在几毫秒内;

在 LAN 上,精度通常为数十微秒。

使用硬件时间戳或硬件参考时钟,亚微秒精度是可能的。

How do I make an NTP server?

By default, chronyd does not operate as an NTP server. You need to add an allow directive to the chrony.conf file in order for chronyd to open the server NTP port and respond to client requests.

allow 192.168.1.0/24

An allow directive with no specified subnet allows access from all IPv4 and IPv6 addresses.

Is chronyd allowed to step the system clock?

By default, chronyd adjusts the clock gradually by slowing it do

By default, chronyd adjusts the clock gradually by slowing it down or speeding it up. If the clock is too far from the true time, it will take a long time to correct the error. The System time value printed by the chronyc’s tracking command is the remaining correction that needs to be applied to the system clock.

makestep 1 3

the clock would be stepped in the first three updates if its offset was larger than one second. Normally, it is recommended to allow the step only in the first few updates, but in some cases (e.g. a computer without an RTC or virtual machine which can be suspended and resumed with an incorrect time) it might be necessary to allow the step on any clock update. The example above would change to

makestep 1 -1
# 精确显示时间
date '+%Y-%m-%d %H:%M:%S.%3N'
# 将系统时间调整为当前时间加上 3 秒
sudo date -s @$(($(date +%s) + 3))
# 查看服务器时间和NTP server偏差 
chronyc tracking
# 查看时间同步源,使用可选参数 -v 来包括详细信息
chronyc sources
chronyc sources -v
# 显示有多少NTP源在线/离线
chronyc activity
# 立即手动同步时间(需要chronyd服务运行)
chronyc makestep

chronyc clients

# 像 ntpdate 一样手动同步时间 使用参数 -q (运行服务执行后停止服务)
chronyd -q 'pool time.windows.com iburst'
# 临时添加一台时间同步服务地址(不会写入配置中),chronyc sources
chronyc add server time.windows.com
# 最后一步,将当前时间和日期写入BIOS,避免重启后失效
hwclock -w
# 显示 BIOS 中实际的时间
hwclock --localtime

timedatectl set-ntp yes

# 默认情况下,系统配置为使用UTC,也可使用本地时间
timedatectl set-local-rtc true   # 将RTC设置为本地时间
timedatectl set-local-rtc false  # 将RTC设置为UTC
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值