Windows NTP网络时间同步设置详解

本文详细介绍了如何在Windows上使用W32tm工具设置和管理NTP网络时间同步,包括修改NTP服务器地址、理解0x9键值的作用以及设置SpecialPollInterval来调整同步间隔。此外,还提到了通过计划任务定期执行时间同步的建议。
部署运行你感兴趣的模型镜像

首先介绍一个命令行,以下是Windows官网文档
Microsoft Docs:https://docs.microsoft.com/zh-cn/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/ff799054(v=ws.11)

W32tm

You can use the W32tm.exe tool to configure Windows Time service (W32time) settings. You can also use W32tm.exe to diagnose problems with the time service. W32tm.exe is the preferred command-line tool for configuring, monitoring, or troubleshooting the Windows Time service.

在cmd中输入 w32tm 可以查看命令帮助。
命令范例
w32tm /config /manualpeerlist:ntp2.aliyun.com /syncfromflags:manual /update
(我这里是用阿里云的NTP服务器)

设置NTP服务器地址的话可以从NTP注册表的值进行修改(不一定非要在控制面板中设置,其实俩效果是一样的)
路径:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\NtpServer
Value Date : ntp2.aliyun.com,0x9

键值数据描述

NameRangeDefault value
NtpServerDNS name or IP address[,0x1,0x2,0x3]time.windows.com,0x1
ValueMeaning
0x1Instead of following the NTP specification, wait for the interval specified in the SpecialPollInterval entry before attempting to recontact this time source. Setting this flag decreases network usage, but it also decreases accuracy.
0x2Use this time source only as a fallback. If all time sources that are not fallbacks have failed, then the system selects one fallback time source at random and uses it.
0x4Set the local computer to operate in symmetric active mode in the association with this source.
0x8Set the local computer to operate in client mode in the association with this source.

我们一般使用的值为0x9的意思是,0x8+0x1,0x8就是将本机定义为NTPClient客户端,向0x9前面的IP地址寻求时间同步,0x1就是加上了SpecialInterval的标志,这个flag启用后,键值SpecialPollInterval随之启用。 如果SpecialPollInterval不启用的话,本机会通过MinPollInterval 和 MaxPollInterval 来定义轮询间隔。

简单来讲0x9的意思就是:决定了自己是个client,要向其他时间源寻求时间同步,并且决定了自己要用SpecialPollInterval这个键值。

SpecialPollInterval这个值定义向之前的IP地址寻求时间同步的轮询间隔。
路径:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient
该项指定手动对等端的特殊轮询间隔(以秒为单位)。当启用 SpecialInterval 0x1 标志时,W32Time 将使用此轮询间隔而非操作系统确定的轮询间隔。
改成了3600,就是时间同步的间隔一小时。

计划任务

可以添加一个计划任务,定时执行下面命令。
w32tm /config /manualpeerlist:ntp2.aliyun.com /syncfromflags:manual /update
w32tm /resync

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值