解决Ubuntu和windows双系统时钟不统一的问题

Ubuntu解决方案

需要注意的是,Ubuntu会自动设置时区和时间,此时如果不进行后续的设置,机器时间就会被改写。本地时间(Local Time)就是我们在系统中使用的时间,它的值虽然正确,但这是以UTC为参照的,与机器时间存在8小时的时差。一旦重启进入仍然将机器时间视为RTC的Windows,则必会导致时间不统一。
自16.04版本起,timedatectl成为Ubuntu的时间管理工具。不带参数运行时,它会输出当前的时间,以及系统时间的一些配置参数。
以下为设置前的timedatectl输出,本地时间为笔者的实际时间,注意观察时差:
Local time: Fri 2018-09-07 22:32:18 CST
Universal time: Fri 2018-09-07 14:32:18 UTC
RTC time: Fri 2018-09-07 14:32:18
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no

具体的操作如下:
第一步:更改硬件时间标准。为了让Ubuntu能正确显示时间,需要运行以下命令,将硬件时间由UTC改为CST。设置完成后,重启电脑生效:
sudo timedatectl set-local-rtc 1

这里要注意的是,Ubuntu官方其实是不推荐如此设置的。再次运行timedatectl,你会发现输出的下方多了一段很长的警告,还加粗了:
Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
‘timedatectl set-local-rtc 0’.

sudo hwclock --localtime --systohc

windows解决方案
shell:
reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值