windows ntp校时

2022-09-19 09:27:49 浏览数 (1)

代码是在≥2012R2的系统上powershell测试的,代码未在≤2008R2的系统上测试;仅供非域环境参考。

只要能上外网、能解析公网域名,腾讯云服务器可以配置内网NTP地址,也可以配置公网NTP地址

time1.tencentyun.com

time2.tencentyun.com

time3.tencentyun.com

time4.tencentyun.com

time5.tencentyun.com

② time1.cloud.tencent.com time2.cloud.tencent.com time3.cloud.tencent.com time4.cloud.tencent.com time5.cloud.tencent.com

③ 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org 0.cn.pool.ntp.org 1.cn.pool.ntp.org 2.cn.pool.ntp.org 3.cn.pool.ntp.org 参考微软官网文档配置: https://docs.microsoft.com/zh-cn/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings https://www.pool.ntp.org/zone/cn https://www.ntppool.org/zh/use.html

https://cloud.tencent.com/document/product/213/30392 配置命令 w32tm /config/manualpeerlist:"0.pool.ntp.org,0x8 1.pool.ntp.org,0xa 2.pool.ntp.org,0xa 3.pool.ntp.org,0xa"/syncfromflags:manual /reliable:yes /update

w32tm /config/manualpeerlist:"0.cn.pool.ntp.org,0x8 1.cn.pool.ntp.org,0xa 2.cn.pool.ntp.org,0xa 3.cn.pool.ntp.org,0xa"/syncfromflags:manual /reliable:yes /update

查询命令

reg query HKLMSYSTEMCurrentControlSetServicesW32TimeParameters | findstr "NtpServer Type"

reg query HKLMSOFTWAREPoliciesMicrosoftW32TimeParameters | findstr "NtpServer Type"

reg query HKLMSOFTWAREWOW6432NodePoliciesMicrosoftW32timeParameters | findstr "NtpServer Type"

reg query HKLMSYSTEMCurrentControlSetServicesW32TimeConfig | findstr "PollInterval"

reg query HKLMSYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient | findstr "PollInterval"

reg query HKLMSOFTWAREPoliciesMicrosoftW32TimeTimeProvidersNtpClient | findstr "PollInterval"

reg query HKLMSOFTWAREWow6432NodePoliciesMicrosoftW32TimeTimeProvidersNtpClient | findstr "PollInterval"

重启w32time服务的命令,配置完了重启服务生效

net stop w32time 2>&1 > $null

w32tm /unregister

w32tm /register

sc.exe triggerinfo w32time delete

sc.exe config w32time start= auto

#sc.exe config w32time start= delayed-auto

sc.exe triggerinfo w32time start/networkon stop/networkoff

net start w32time

手动同步的命令

w32tm /resync /rediscover

w32tm /resync /rediscover

w32tm /resync /rediscover

0 人点赞