w32time服务自动更新时间(NTP)

简介

NTP:“用来使计算机时间同步化的一种协议


功能要求:

开机后自动更新时间,定时与时间服务器校正时间

实现:

同步频率

项:SYSTEM\\CurrentControlSet\\Services\\W32Time\\TimeProviders\\NtpClient

值:SpecialPollInterval

数据:1800(30X60秒)

设置自启动

项:SYSTEM\\CurrentControlSet\\Services\\W32Time\\TriggerInfo\\0

值:Type

数据:0

设置本机为客户端

项:SYSTEM\ CurrentControlSet\\Services\\W32Time\\TimeProviders\\NtpClient

值:Enabled

数据:1

设置为与外部时间源同步

项:SYSTEM\CurrentControlSet\\Services\\W32Time\\Config

值:AnnounceFlags

数据:10

设置为NTP服务同步时间

项:SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters

值:Type

数据:"NTP"

设置外部时间源地址

项:SYSTEM\\CurrentControlSet\\Services\\W32Time\\Parameters

值:NtpServer

数据:"cn.pool.ntp.org,0x1"

备注:时间源:

cn.ntp.org.cn NTP授时快速域名,具有NTP时间服务池)(推荐使用)

ntp.sjtu.edu.cn  (上海交通大学网络中心NTP服务器地址)

cn.pool.ntp.org

ntp4.aliyun.com 阿里云时间服务(本次使用)


打开w32time服务并设置为自动

请百度自行实现

更新W32tm的配置文件

cmdw32tm /config /update

发送时间同步命令

cmdw32tm /resync

 

注意:需打开时间同步端口为:123端口(TCP,UDP

其他CMD命令:

查询上一次对时的时间源w32tm /query /source

启动服务 net start w32time

停止服务 net stop w32time

注册服务 w32tm /register

卸载服务 w32tm /unregister

设置时间源 w32tm /config /manualpeerlist:ntp4.aliyun.com /update

与时间源对时 w32tm /resync

更新配置文件 w32tm /config /update

官方文档:

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc773263(v%3dws.10)



猜你喜欢

转载自blog.csdn.net/xyb_l_code/article/details/79914712
今日推荐