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

news2024/7/6 20:05:31

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.coloradmin.cn/o/1641090.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

AJ-Report开源数据大屏 verification;swagger-ui RCE漏洞复现

0x01 产品简介 AJ-Report是一个完全开源的BI平台,酷炫大屏展示,能随时随地掌控业务动态,让每个决策都有数据支撑。多数据源支持,内置mysql、elasticsearch、kudu等多种驱动,支持自定义数据集省去数据接口开发,支持17+种大屏组件,不会开发,照着设计稿也可以制作大屏。三…

Linux进程——Linux下常见的进程状态

前言:在进程学习这一块,我们主要学习的就是PCB这个进程控制块,而PBC就是用来描述进程的结构体,而进程状态就是PCB结构体中的一个变量。 本篇主要内容: 操作系统中的进程状态Linux下的进程状态 在开始之前,我…

MLP手写数字识别(2)-模型构建、训练与识别(tensorflow)

查看tensorflow版本 import tensorflow as tfprint(Tensorflow Version:{}.format(tf.__version__)) print(tf.config.list_physical_devices())1.MNIST的数据集下载与预处理 import tensorflow as tf from keras.datasets import mnist from keras.utils import to_categori…

排序算法--直接选择排序

前提: 选择排序:选择排序(Selection sort)是一种比较简单的排序算法。它的算法思想是每一次从待排序的数据元素中选出最小(或最大)的一个元素,存放在序列的起始位置,直到全部待排序的数据元素排完。 话不多说,直接放图…

Xamarin.Android项目显示Properties

在 Visual Studio 2022 中,如果您需要调出“Properties”(属性)窗口,您可以使用以下几种方法: 快捷键: 您可以按 F4 快速打开当前选择项的“Properties”窗口。

postman中百度preview无法加载的解决方案

问题 在使用postman关联时,百度接口与天气接口已使用glb_city关联,但在百度接口发送请求时,发现preview无法加载 解决方案 1、进入百度 百度全球领先的中文搜索引擎、致力于让网民更便捷地获取信息,找到所求。百度超过千亿的中…

【云原生】Docker 实践(二):什么是 Docker 的镜像

【Docker 实践】系列共包含以下几篇文章: Docker 实践(一):在 Docker 中部署第一个应用Docker 实践(二):什么是 Docker 的镜像Docker 实践(三):使用 Dockerf…

在M1芯片安装鸿蒙闪退解决方法

在M1芯片安装鸿蒙闪退解决方法 前言下载鸿蒙系统安装完成后,在M1 Macos14上打开闪退解决办法接下来就是按照提示一步一步安装。 前言 重新安装macos系统后,再次下载鸿蒙开发软件,竟然发现打不开。 下载鸿蒙系统 下载地址:http…

eNSP-抓包解析HTTP、FTP、DNS协议

一、环境搭建 1.http服务器搭建 2.FTP服务器搭建 3.DNS服务器搭建 二、抓包 三、http协议 1.HTTP协议,建立在FTP协议之上 2.http请求 3.http响应 请求响应报文参考:https://it-chengzi.blog.csdn.net/article/details/113809803 4.浏览器开发者工具抓包…

堆栈打印跟踪Activity的启动过程(基于Android10.0.0-r41),framework修改,去除第三方app的倒计时页面

文章目录 堆栈打印跟踪Activity的启动过程(基于Android10.0.0-r41),framework修改,去除第三方app的倒计时页面1.打印异常堆栈2.去除第三方app的倒计时页面3.模拟点击事件跳过首页进入主页 堆栈打印跟踪Activity的启动过程(基于Android10.0.0-r41)&#x…

SpringCloud微服务项目创建流程

为了模拟微服务场景,学习中为了方便,先创建一个父工程,后续的工程都以这个工程为准,实用maven聚合和继承,统一管理子工程的版本和配置。 后续使用中只需要只有配置和版本需要自己规定之外没有其它区别。 微服务中分为…

MLP实现fashion_mnist数据集分类(2)-函数式API构建模型(tensorflow)

使用函数式API构建模型,使得模型可以处理多输入多输出。 1、查看tensorflow版本 import tensorflow as tfprint(Tensorflow Version:{}.format(tf.__version__)) print(tf.config.list_physical_devices())2、fashion_mnist数据集分类模型 2.1 使用Sequential构建…

4 Spring AOP

目录 AOP 简介 传统开发模式 先来看一个需求 解决方案 AOP 图示 Spring 启用 AspectJ 基于 xml 配置 创建 pom.xml 创建 UserService 借口和 UserServiceImpl实现类 创建 LogAdvice 日志通知 创建 log4j.properties 重点:创建 spring-context-xml.xml 配…

MyBatis:mybatis基础操作

MyBatis基础操作 新增 接口方法 Insert() insert();删除 接口方法 Delete() delete();Delete("delete from emp where id #{id}") public abstract void delete(Integer id) //如果只传了一个形参,括号内可以随意写修改 接口方法 Update() update();查询 接…

Jupyter Notebook魔术命令

Jupyter Notebook是一个基于网页的交互式笔记本,支持运行多种编程语言。 Jupyter Notebook 的本质式一个Web应用程序,便于创建和共享文学化程序文档,支持实现代码,数学方程,可视化和markdown。用途包括:数据…

MATLAB中自定义栅格数据地理坐标R,利用geotifwrite写入tif

场景描述: 有时候将nc格式的数据转成tiff,或者是将一个矩阵输出成带有地理坐标信息tiff数据时,常常涉及到空间参考的定义和geotiffwrite()函数。 问题描述: 以全球数据为例,今天发现在matlab中对矩阵进行显示后&…

【大模型学习】大模型相关概念

知识库 Embeding 嵌入,又称向量化、矢量化。 Prompt engineer 提示词工程 提示工程技巧 RAG 检索增强生成,提高文本的准确性和丰富性。 Fine tuning 微调,优化已有人工智能模型以适应特定任务的技术。 AI agent AI代理人&…

华为机考入门python3--(19)牛客19- 简单错误记录

分类:字符串 知识点: 分割字符串 my_str.split(\\) 字符串只保留最后16位字符 my_str[-16:] 列表可以作为队列、栈 添加元素到第一个位置 my_list.insert(0, elem) 增加元素到最后一个位置 my_list.append(elem) 删除第一个 my_list.pop(0)…

Python中的数据可视化:阶梯图matplotlib.pyplot.step()

【小白从小学Python、C、Java】 【计算机等考500强证书考研】 【Python-数据分析】 Python中的数据可视化: 阶梯图 matplotlib.pyplot.step() [太阳]选择题 matplotlib.pyplot.step()的功能是? import matplotlib.pyplot as plt import numpy as…

基于Springboot的旅游管理系统(有报告)。Javaee项目,springboot项目。

演示视频: 基于Springboot的旅游管理系统(有报告)。Javaee项目,springboot项目。 项目介绍: 采用M(model)V(view)C(controller)三层体系结构&…