当前位置: 首页 > news >正文

Ubuntu20.04 用 `hwclock` 或 `timedatectl` 设置RTC硬件时钟为本地时区

Ubuntu20.04用 hwclocktimedatectl 设置硬件时区为本地时区

可以用hwclock命令

sudo hwclock --localtime --systohc

👆效果等同👇 , --localtime的简写是-l ; --systohc的简写是-w

sudo hwclock -l -w

也可以用timedatectl命令 👆效果等同👇

sudo timedatectl set-local-rtc 1




hwclock -l -w


-l, --localtime 本地时区 ; -u, --utc 统一世界协调时

   Indicate which timescale the Hardware Clock is set to.

指示硬件时钟设置为哪个时间刻度。

The Hardware Clock may be configured to use either the UTC or the local timescale, but nothing in the clock itself says which alternative is being used. The --localtime or --utc options

硬件时钟可以配置为使用UTC或本地时间刻度,但时钟本身没有说明正在使用哪种替代。--localtime--utc选项

give this information to the hwclock command. If you specify the wrong one (or specify neither and take a wrong default), both setting and reading the Hardware Clock will be incorrect.

将此信息提供给hwclock命令。如果您指定了错误的硬件时钟(或者既不指定也不使用错误的默认值),则硬件时钟的设置和读取都将不正确。

If you specify neither --utc nor --localtime then the one last given with a set function (--set, --systohc, or --adjust), as recorded in /etc/adjtime, will be used. If the adjtime file doesn’t exist, the default is UTC.

如果既不指定--utc也不指定--localtime,则将使用最后一个用set函数(–set、–systohc或–adjust)给定的,如/etc/adjtime中所记录的。如果adjtime文件不存在,默认值为UTC。

Note: daylight saving time changes may be inconsistent when the Hardware Clock is kept in local time. See the discussion below, under LOCAL vs UTC.
注意:当硬件时钟保持在本地时间时,夏令时变化可能不一致。请参阅下面的讨论,在本地与UTC下。



-w = --systohc 将系统时间写入硬件时间

	Set the Hardware Clock from the System Clock, and update the timestamps in /etc/adjtime. With the --update-drift option also (re)calculate the drift factor. Try it without the option if --systohc fails. See --update-drift below.

systohc可分解为sys系统to到h硬件c时钟
从系统时钟设置硬件时钟,并在/etc/adjtime中更新时间戳。使用--update-drift选项还(重新)计算漂移因子。如果--systohc失败,请尝试不使用该选项。




timedatectl set-local-rtc 1


  • 设置真实时钟(电子元件硬时钟)的时区为本地时区👇
sudo timedatectl set-local-rtc 1
  • 设置真实时钟(电子元件硬时钟)的时区为国际时区UTC👇
sudo timedatectl set-local-rtc 0

set-local-rtc

set-local-rtc [BOOL]
Takes a boolean argument. If “0”, the system is configured to
maintain the RTC in universal time. If “1”, it will maintain the
RTC in local time instead. Note that maintaining the RTC in the
local timezone is not fully supported and will create various
problems with time zone changes and daylight saving adjustments. If
at all possible, keep the RTC in UTC mode. Note that invoking this
will also synchronize the RTC from the system clock, unless
–adjust-system-clock is passed (see above). This command will
change the 3rd line of /etc/adjtime, as documented in hwclock(8).
接受一个布尔参数。如果为“0”,则系统配置为
保持RTC为世界时。如果“1”,它将保持
改为当地时间的RTC。注意,维护RTC在
不完全支持本地时区,并将创建各种
时区更改和夏令时调整的问题。如果
尽可能保持RTC为UTC模式。注意,调用这个
也将同步RTC从系统时钟,除非
-adjust-system-clock被传递(见上文)。

set-local-rtc [布尔值,0为否,1为是]

实时时钟的缩写是 RTC (Real_Time Clock)。RTC 是集成电路,通常称为时钟芯片。
实时时钟芯片是日常生活中应用最为广泛的消费类电子产品之一。它为人们提供精确的实时时间,或者为电子系统提供精确的时间基准,实时时钟芯片大多采用精度较高的晶体振荡器作为时钟源。有些时钟芯片为了在主电源掉电时,还可以工作,需要外加电池供电。

set-local-rtc 表示是否设置真实时钟(电子元件硬时钟)的时区为本地时区, 取值01

  • 0 表示 否, RTC=UTC
    UTC一般指协调世界时。 协调世界时,又称世界统一时间、世界标准时间、国际协调时间。
  • 1 表示 是, RTC=LOCAL本地时区
http://www.lryc.cn/news/1917.html

相关文章:

  • 大学物理·第15章【量子物理】
  • 2010-2019年290个地级市经济发展与城市绿化数据
  • 【CSS 布局】-多列布局
  • 从C语言向C++过渡
  • Matter 研讨会回顾(第三期)|乐鑫 Matter 免开发方案与证书服务介绍
  • 函数栈帧的创建和销毁——“C”
  • 腾讯云对象存储+企业网盘 打通数据链“最后一公里
  • 在浏览器输入url到发起http请求,这过程发生了什么
  • PyTorch学习笔记:nn.ReLU——ReLU激活函数
  • 同步线程
  • 服务端返回内容跨域CORS之后,也在chrome/edge浏览器里显示出响应信息
  • DHCP中继及配置
  • 中国社科院与美国杜兰大学金融管理硕士,让我们相遇在春暖花开时
  • MySQL---单表查询、多表查询
  • 3年自动化测试这水平?我还不如去招应届生
  • 5 个自定义 React Hooks 将改变你的代码
  • Java学习笔记-03(API阶段)
  • Django自定义模板标签的使用详解
  • 洗地机怎么选?洗地机品牌排行榜
  • CSS的元素显示模式
  • 【MySQL Shell】8.9.1 在 InnoDB ClusterSet 中隔离集群
  • Ubuntu20.04+cuda11.2+cudnn8.1+Anaconda3安装tensorflow-GPU环境,亲测可用
  • 剑指Offer 第27天 JZ75 字符流中第一个不重复的字符
  • 科研试剂供应1476737-97-9,Bis-PEG2-endo-BCN可发生点击反应
  • Zabbix 构建监控告警平台(一)--部署安装
  • 【nodejs】nodejs入门核心知识(命令行使用、内置模块、node 模块化开发)
  • 5. Spring 事务
  • 【堆】数据结构堆的实现(万字详解)
  • Docker进阶 - 9. docker network 之自定义网络
  • springcloud-工程创建(IDEA)