2个或更多设备之间的时间同步 [英] Time sync between 2 or more devices

查看:326
本文介绍了2个或更多设备之间的时间同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何同步我的Windows 10 iot无人值守的电脑(英特尔NUC)以获得确切的时间?

how can i sync my windows 10 iot unattended pc's(intel NUC) to get the exact time?

推荐答案

Hello Ryan,

Hello Ryan,

默认情况下,设备会在重新启动时从  time.windows.com
同步日期时间,更多信息请参阅此文档(https://docs.microsoft.com/en-us/windows-hardware/manufacture / iot / update-the-time-server )。

By default, the device will sync the datetime from time.windows.com when rebooting, more information please refer to this document(https://docs.microsoft.com/en-us/windows-hardware/manufacture/iot/update-the-time-server).

如果要以自定义方式同步日期时间,可以使用NTP客户端获取激励时间。以下是通过IoT.Ntp库来同步NTP服务器的日期时间的示例。

If you want to sync the datetime in your custom way, you can use NTP Client to get the excart time. Following is an example via IoT.Ntp library to sync datetime fro NTP server.

            var ntpClient = new NtpClient();
            var syncTime = await ntpClient.GetAsync("0.cn.pool.ntp.org");
            if(syncTime != null)
            {
                Windows.System.DateTimeSettings.SetSystemDateTime(syncTime.Value);
            }  

请注意,您应该为UWP添加Windows IoT Extension的引用,并添加  应用程序的'系统管理'功能。

Please note that, you should add the reference of Windows IoT Extension for the UWP, and add the 'System Management' capability for the app.

如果您不想以编程方式执行
,您可以创建一个定时任务计划,以强制通过powershell命令重新同步时间。您可以参考这篇文章关于schtasks的详细用法( https://docs.microsoft.com / en-us / windows / desktop / taskschd / schtasks )。

If you do not want to do that programmatically , you can create a timed task schedule to force a time re-sync via powershell command. You can refer to this article about the detailed usage of schtasks(https://docs.microsoft.com/en-us/windows/desktop/taskschd/schtasks).

schtasks /Create /SC DAILY /TN TimeSync /TR "w32tm /resync"

最好的问候,

Michael


这篇关于2个或更多设备之间的时间同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆