windows时间同步


查看NTP服务器时间

w32tm /stripchart /computer:10.36.20.18

检查NTP和客户端的时间差异

w32tm /stripchart /computer:time.windows.com /samples:5(采样的次数) /dataonly

w32tm /stripchart /computer:time.windows.com /samples:5 /dataonly

修改时间间隔

regedit进入注册表,打开如下位置:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient

编辑SpecialPollInterval值,默认十进制值604800=7(天)*24(小时)*60(分钟)*60(秒),修改成你需要的时间间隔即可。

批处理

@echo off
net stop "Windows Time"
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient /v SpecialPollInterval /t REG_DWORD /d 3600 /f
net start "Windows Time" || echo 时间同步频率修改失败! && pause >nul && exit 
echo 时间同步频率修改为1小时/次! && ping 127.1 -n 3 >nul && exit