zl程序教程

您现在的位置是:首页 >  系统

当前栏目

Linux/Windows双系统时间同步

LinuxWindows同步 时间 双系统
2023-09-14 09:11:26 时间

Windows和Linux分别用的是RTC和UTC而导致产生8小时的时间差

方案1:linux改为RTC时间(systemd 默认硬件时钟为协调世界时(UTC))
sudo timedatectl set-local-rtc 1
or
sudo timedatectl set-local-rtc true


方案2:
更好的方法是在 Windows 那边改注册表,让 Windows 认 UTC。似乎只有 Windows 会默认认为硬件时间是本地时间

# 以管理员身份使用运行
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_DWORD /f

# 以上方法无效或64位系统:
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_QWORD /f


可以把如下内容保存为*.reg:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001

其他:
linux系统时间网络同步:
sudo timedatectl set-ntp true

ref:
https://www.jianshu.com/p/42e6a8289d4d
https://developer.aliyun.com/article/522278
https://codeantenna.com/a/AObiCizXEo
https://wiki.archlinux.org/title/System_time