Ubuntu20.04用 hwclock
或 timedatectl
设置硬件时区为本地时区
可以用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 表示是否设置真实时钟(电子元件硬时钟)的时区为本地时区, 取值0
或1
0
表示 否, RTC=UTC
UTC一般指协调世界时。 协调世界时,又称世界统一时间、世界标准时间、国际协调时间。1
表示 是, RTC=LOCAL本地时区