如何在命令中从 ntp 时间服务器同步 Windows 时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22862236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to sync windows time from a ntp time server in command
提问by Nick Dong
I am working on windows 7. I can sync time of win7 from a ntp linux server manually. How can I do that in command prompt. So I can run it on windows startup. And windows task plan not work for me. The time should be like this:
我在 Windows 7 上工作。我可以手动从 ntp linux 服务器同步 win7 的时间。我怎么能在命令提示符下做到这一点。所以我可以在 Windows 启动时运行它。Windows 任务计划对我不起作用。时间应该是这样的:
Linux server --> windows 7.
Any one knows that? Thank you. I can read msdn.
有人知道吗?谢谢你。我可以阅读msdn。
采纳答案by Lo?c MICHEL
Use net time
net time \\timesrv /set /yes
使用净时间
net time \\timesrv /set /yes
after your comment try this one in evelated prompt :
在您发表评论后,请在升级提示中尝试此操作:
w32tm /config /update /manualpeerlist:yourtimerserver
回答by Domenico Zinzi
net stop w32time
w32tm /config /syncfromflags:manual /manualpeerlist:"0.it.pool.ntp.org 1.it.pool.ntp.org 2.it.pool.ntp.org 3.it.pool.ntp.org"
net start w32time
w32tm /config /update
w32tm /resync /rediscover
.BAT Sample File: https://gist.github.com/thedom85/dbeb58627adfb3d5c3af
.BAT 示例文件:https: //gist.github.com/thedom85/dbeb58627adfb3d5c3af
I also recommend this program: http://www.timesynctool.com/
我也推荐这个程序:http: //www.timesynctool.com/
回答by CONvid19
If you just need to resync
windows time, open an elevated command promptand type:
如果您只需要resync
Windows 时间,请打开提升的命令提示符并键入:
w32tm /resync
C:\WINDOWS\system32>w32tm /resync
Sending resync command to local computer
The command completed successfully.
回答by starlocke
While the w32tm /resync
in theory does the job, it only does so under certain conditions. When "down to the millisecond" matters, however, I found that Windows wouldn't actually make the adjustment; as if "oh, I'm off by 2.5 seconds, close enough bro, nothing to see or do here".
虽然w32tm /resync
理论上可以完成这项工作,但它仅在某些条件下才会这样做。然而,当“精确到毫秒”很重要时,我发现 Windows 实际上不会进行调整;好像“哦,我走了 2.5 秒,离兄弟很近,这里没什么可看或可做的”。
In order to truly force the resync (Windows 7):
为了真正强制重新同步(Windows 7):
- Control Panel -> Date and Time
- "Change date and time..." (requires Admin privileges)
- Add or Subtract a few minutes (I used -5 minutes)
- Run "cmd.exe" as administrator
w32tm /resync
- Visually check that the seconds in the "Date and Time" control panel are ticking at the same time as your authoritative clock(s). (I used
watch -n 0.1 date
on a Linux machine on the network that I had SSH'd over into)
- 控制面板 -> 日期和时间
- “更改日期和时间...”(需要管理员权限)
- 加减几分钟(我用了 -5 分钟)
- 以管理员身份运行“cmd.exe”
w32tm /resync
- 目视检查“日期和时间”控制面板中的秒数是否与您的权威时钟同时计时。(我
watch -n 0.1 date
在 SSH 连接到的网络上的 Linux 机器上使用)
--- Rapid Method ---
--- 快速方法 ---
- Run "cmd.exe" as administrator
net start w32time
(Time Service must be running)time 8
(where 8 may be replaced by any 'hour' value, presumably 0-23)w32tm /resync
- Jump to 3, as needed.
- 以管理员身份运行“cmd.exe”
net start w32time
(时间服务必须正在运行)time 8
(其中 8 可以替换为任何“小时”值,大概是 0-23)w32tm /resync
- 根据需要跳到 3。