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

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

Ubuntu22.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/1735.html

相关文章:

  • Node=>Express路由 学习2
  • Android 面试三部曲——你做到了几点?
  • windeployqt实现一键打包
  • ESP32S3系列--SPI主机驱动详解(二)
  • 51单片机15单片机 时钟芯片DS1302【更新中】
  • SaleSmartly(ss客服)带你了解:缩短B2B销售周期的秘诀
  • 九龙证券|A股苏州板块迎来“200+”里程碑
  • vcruntime140_1.dll无法继续执行代码,怎么解决这种问题?
  • 正大国际期货:外盘震荡行情的特征及突破信号的确立
  • 【ESP 保姆级教程】玩转emqx数据集成篇④ ——数据桥接之HTTP服务
  • 蓝桥杯算法训练合集十三 1.P06022.P07033.逗志芃的危机4.唯一的小可爱5.JOE的矩阵
  • 切换分支报错:Untracked Files Prevent Checkout
  • endo-BCN-PEG4-Palmitic,环丙烷环辛炔四聚乙二醇-Palmitic包装灵活
  • 多传感器融合定位十一-基于滤波的融合方法Ⅱ
  • JAVA使用poi解析execl解决数值被转为科学计数法(如:手机号、身份证号、电话、等)解决方法
  • hive中substring_index()的使用
  • LocalDateTime设置时间的年、月、日、时、分、秒、纳秒
  • C语言rand和srand用法详解
  • 安装作业
  • 电压放大器在非共线混频方法检测混凝土中的应用
  • 二十四、Gtk4-GtkExpression
  • Oracle Dataguard(主库为 Oracle rac 集群)配置教程(02)—— Oracle RAC 主库的相关操作
  • midjournery AI绘画使用指南
  • iptables防火墙SNAT和DNAT
  • python | 第二章考试题和练习题
  • Mysql 存储引擎设计:xa协议相关接口功能及实现
  • 字符串常量池
  • 让技术更有温度,腾讯Light 点亮公益之光
  • 电子采购一体化解决方案
  • SAP COPA 获利能力分析深度解析