20240503解决Ubuntu20.04和WIN10双系统下WIN10的时间异常的问题

news/2024/5/20 20:24:29

20240503解决Ubuntu20.04和WIN10双系统下WIN10的时间异常的问题
2024/5/3 9:33


缘起:因为工作需要,编译服务器上都会安装Ubuntu20.04。
但是因为WINDOWS强悍的生态系统,偶尔还是有必须要用WINDOWS的时候,于是也安装了WIN10。

双系统的通病,先安装WIN10,再安装Ubuntu20.04之后就会出现WIN10的系统时间晚8个小时的问题!
百度之后:WIN10 ubuntu20.04 时间

1. 原因分析
出现这种情况的原因是 Windows 和 Ubuntu它们在默认情况下看待硬件时间(主板上的BOIS显示的时间)的方式 不一样。

我们先来了解一下关于时间的概念 :
UTC,即Universal Time Coordinated, 协调世界时
GMT,即Greenwich Mean Time, 格林尼治平时
RTC时间,即Real-time clock,是电脑的硬件时间
Windows 与 Linux 缺省看待系统硬件时间的方式是不一样的:

Linux 时钟分为系统时钟(System Clock)和硬件(RTC)时钟。Linux把硬件时间当作 UTC,系统时间是UTC时间经过换算得来的。比如说北京时间是GMT+8,则系统中显示时间是硬件时间+8。
Windows把系统硬件(RTC)时间当作本地时间(local time),即系统时间跟BIOS中显示的时间(RTC)是一样的。


rootroot@rootroot-desktop:~$ sudo apt-get update
rootroot@rootroot-desktop:~$ timedatectl set-local-rtc 1 --adjust-system-clock
rootroot@rootroot-desktop:~$ sudo apt-get install ntpdate
rootroot@rootroot-desktop:~$ sudo ntpdate time.windows.com
rootroot@rootroot-desktop:~$ sudo hwclock --localtime --systohc

rootroot@rootroot-desktop:~$ sudo reboot

# 推荐使用
$ sudo ntpdate ntp.ntsc.ac.cn

https://blog.csdn.net/ZChen1996/article/details/106131224/?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-4--blog-110142773.235^v43^pc_blog_bottom_relevance_base4&spm=1001.2101.3001.4242.3&utm_relevant_index=7
Win10 + Ubuntu20.04双系统下时间不同步问题

rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo apt-get update
[sudo] password for rootroot: 
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2,892 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [743 kB]                                                                                                                              
Get:7 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [436 kB]                                                                                                                             
Get:8 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [957 kB]                                                                                                                         
Get:9 http://security.ubuntu.com/ubuntu focal-security/universe i386 Packages [656 kB]                                                                                                                          
Get:10 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [201 kB]                                                                                                                        
Hit:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease                                                                                                                                                
Get:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease [114 kB]                                                                                                                               
Hit:4 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease                                                                                                                                      
Get:11 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/main amd64 Packages [3,269 kB]                                                                                                                  
Get:12 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/main i386 Packages [968 kB]                                                                                                                     
Get:13 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/main Translation-en [518 kB]                                                                                                                    
Get:14 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/universe amd64 Packages [1,183 kB]                                                                                                              
Get:15 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/universe i386 Packages [783 kB]                                                                                                                 
Get:16 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/universe Translation-en [284 kB]                                                                                                                
Fetched 13.1 MB in 25s (524 kB/s)                                                                                                                                                                               
Reading package lists... Done
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ timedatectl set-local-rtc 1 --adjust-system-clock
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo apt-get install ntpdate
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ntpdate is already the newest version (1:4.2.8p12+dfsg-3ubuntu4.20.04.1).
The following packages were automatically installed and are no longer required:
  chromium-codecs-ffmpeg-extra gstreamer1.0-vaapi libgstreamer-plugins-bad1.0-0 libva-wayland2
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo ntpdate time.windows.com
 3 May 09:03:29 ntpdate[3002]: adjust time server 20.189.79.72 offset -0.013272 sec
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo hwclock --localtime --systohc
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo reboot

效果图:


参考资料:
【这个方法时搞不定的!】
https://blog.csdn.net/X_T_S/article/details/110142773
解决Ubuntu(20.04)和Windows10双系统时间不同步问题

rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo apt-get install ntpdate
[sudo] password for rootroot: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  chromium-codecs-ffmpeg-extra gstreamer1.0-vaapi libgstreamer-plugins-bad1.0-0 libva-wayland2
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  ntpdate
0 upgraded, 1 newly installed, 0 to remove and 56 not upgraded.
Need to get 48.8 kB of archives.
After this operation, 178 kB of additional disk space will be used.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates/universe amd64 ntpdate amd64 1:4.2.8p12+dfsg-3ubuntu4.20.04.1 [48.8 kB]
Fetched 48.8 kB in 21s (2,364 B/s) 
Selecting previously unselected package ntpdate.
(Reading database ... 194529 files and directories currently installed.)
Preparing to unpack .../ntpdate_1%3a4.2.8p12+dfsg-3ubuntu4.20.04.1_amd64.deb ...
Unpacking ntpdate (1:4.2.8p12+dfsg-3ubuntu4.20.04.1) ...
Setting up ntpdate (1:4.2.8p12+dfsg-3ubuntu4.20.04.1) ...
Processing triggers for man-db (2.9.1-1) ...
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo ntpdate time.windows.com
 3 May 08:54:53 ntpdate[3089]: adjust time server 20.189.79.72 offset -0.021819 sec
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo hwclock --localtime --systohc
rootroot@rootroot-desktop:~$ 
rootroot@rootroot-desktop:~$ sudo reboot


http://www.mrgr.cn/p/10604547

相关文章

什么是虚拟货币?

随着科技的进步,虚拟货币逐渐进入公众视野,其影响深远且复杂。本文将从专业角度分析虚拟货币的发展现状、未来趋势,以及面临的挑战,并尝试提出一些思考。 一、虚拟货币的定义与现状 虚拟货币是一种基于区块链技术的数字资产&…

欧洲杯/奥运会-云直播

欧洲杯/奥运会要来了,如何升级自己的网站让你的顾客都能观赏直播已提高用户量呢?! 【功能完善、平滑兼容】 云直播支持 RTMP 推流、 HLS 源站等多种直播源接入方式,提供直播 SDK,支持多终端适配,上行码率…

【C++】详解STL容器之一的deque和适配器stack,queue

目录 deque的概述 deque空间的结构 deque的迭代器 deque的数据设计 deque的优缺点 适配器的概念 ​编辑 stack的概述 stack的模拟实现 queue的概述 queue的模拟实现 deque的概述 deque的设计参考了另外两大容器vector和list。可参考下面两篇文章 详解vector&#x…

【LLM 论文】Least-to-Most Prompting 让 LLM 实现复杂推理

论文:Least-to-Most Prompting Enables Complex Reasoning in Large Language Models ⭐⭐⭐ Google Research, ICLR 2023 论文速读 Chain-of-Thought(CoT) prompting 的方法通过结合 few-show prompt 的思路,让 LLM 能够挑战更具…

漏洞管理是如何在攻击者之前识别漏洞从而帮助人们阻止攻击的

漏洞管理 是主动查找、评估和缓解组织 IT 环境中的安全漏洞、弱点、差距、错误配置和错误的过程。该过程通常扩展到整个 IT 环境,包括网络、应用程序、系统、基础设施、软件和第三方服务等。鉴于所涉及的高成本,组织根本无法承受网络攻击和数据泄露。如果…

【springboot基础】如何搭建一个web项目?

正在学习springboot,还是小白,今天分享一下如何搭建一个简单的springboot的web项目,只要写一个类就能实现最基础的前后端交互,实现web版helloworld ,哈哈,虽然十分简陋,但也希望对你理解web运作…

python 和 MATLAB 都能绘制的母亲节花束!!

hey 母亲节快到了,教大家用python和MATLAB两种语言绘制花束~这段代码是我七夕节发的,我对代码进行了简化,同时自己整了个python版本 MATLAB 版本代码 function roseBouquet_M() % author : slandarer% 生成花朵数据 [xr,tr]meshgrid((0:24).…

STM32使用L9110驱动电机自制小风扇

1.1 介绍: 该电机控制模块采用L9110电机控制芯片。该芯片具有两个TTL/CMOS兼容输入端子,并具有抗干扰特性:具有高电流驱动能力,两个输出端子可直接驱动直流电机,每个输出端口可提供750800mA动态电流,其峰值…

AlphaFold3: Google DeepMind的的新突破

AlphaFold 3的论文今天在Nature期刊发表啦!这可是AI在生物领域最厉害的突破的最新版本。AlphaFold-3的新招就是用扩散模型去"画出"分子的结构。它一开始先从一团模模糊糊的原子云下手,然后慢慢透过去噪把分子变得越来越清楚。 Alphafold3 我们活在一个从Llama和Sora那…

【C++】string类的使用

目录 string类对象的默认成员函数 string类对象的容量操作 string中元素访问及遍历 遍历方式1:下标[] 遍历方式2: 迭代器 遍历方式3: 范围for string类对象的修改操作 string类非成员函数 总结 string,也就是串或者字符数组,可以扩容&a…

第十届山东省大学生程序设计竞赛题解(A、F、M、C)

部分代码define了long long,请记得开long long A. Calandar 把年份、月份、单个的天数全都乘以对应的系数转化成单个的天数即可,注意最后的结果有可能是负数,要转化成正数。发现技巧是:(ans % 5 + 5) % 5。? 还有注意不能这样写,答案不正确。或许是因为取模运算没有这样的…

jmeter后置处理器提取到的参数因为换行符导致json解析错误

现象: {"message":"JSON parse error: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Ill…

网页主题自动适配:网页跟随系统自动切换主题

主题切换是网站设计中一个非常有趣的功能,它允许用户在多种预先设计的样式之间轻松切换,以改变网站的视觉表现。最常见的就是白天和黑夜主题的切换,用户可以根据自己的喜好进行设置。 除了让用户手动去切换主题外,如果能够让用户第…

(七)JSP教程——session对象

浏览器和Web服务器之间的交互通过HTTP协议来完成,HTTP协议是一种无状态的协议,服务器端无法保留浏览器每次与服务器的连接信息,无法判断每次连接的是否为同一客户端。为了让服务器端记住客户端的连接信息,可以使用session对象来记…

基于springboot+jsp+Mysql的商务安全邮箱邮件收发

开发语言:Java框架:springbootJDK版本:JDK1.8服务器:tomcat7数据库:mysql 5.7(一定要5.7版本)数据库工具:Navicat11开发软件:eclipse/myeclipse/ideaMaven包:…

定时将系统时间更新在日志文件中

获取当前系统时间,把时间转换为特定格式”yy年mm月dd日 星期x tt:mm:ss”,并每隔1s写入到本地磁盘中一个叫做log.txt的文本中,如果文本不存在则创建V1.0 2024年5月9日 发布于博客园实现:设计程序,获取当前系统时间,把时间转换为特定格式”yy年mm月dd日 星期x tt:mm:ss”,…

jQuery-1.语法、选择器、节点操作

jQuery jQueryJavaScriptQuery&#xff0c;是一个JavaScript函数库&#xff0c;为编写JavaScript提供了更高效便捷的接口。 jQuery安装 去官网下载jQuery&#xff0c;1.x版本练习就够用 jQuery引用 <script src"lib/jquery-1.11.2.min.js"></script>…

RK3568 学习笔记 : u-boot 千兆网络无法 ping 通PC问题的解决方法二

参考 RK3568 学习笔记 : u-boot 千兆网络无法 ping 通PC问题的解决 前言 rk3568 rockchip 提供的 u-boot&#xff0c;默认的设备树需要读取 单独分区 resouce.img 镜像中的 设备树文件&#xff0c;也就是 Linux 内核的设备树 dtb 文件&#xff0c;gmac 网络才能正常的 ping 通…

Marin说PCB之国产电源芯片方案 ---STC2620Q

随着小米加入的造车大家庭&#xff0c;让这个本来就卷的要死的造车大家庭更加卷了。随之带来的蝴蝶效应就是江湖上各个造成门派都开始了降本方案的浪潮啊&#xff0c;开始打响价格战了。各家的新能源车企也是不得不开始启动了降本方案的计划了&#xff0c;为了应对降价的浪潮。…

3月空气净化器市场数据分析,热门品牌排行榜揭晓!

三月上旬以来&#xff0c;中国空气净化器行业的规模持续扩大&#xff0c;市场规模和消费需求也在不断提升&#xff0c;消费者对高质量空气的需求增加。智能化是当前空气净化器市场的一个重要发展方向&#xff0c;这类产品集成了空气过滤、监测等功能&#xff0c;满足了现代消费…