Linux:Ubuntu20,22,Debian10,Fedora36,CentOS9 将硬件时钟设为本地 笔记221111

将系统时间设置到硬件时间,设置硬件时区为本地时区
sudo hwclock --localtime --systohc

效果等同 , --systohc的简写是-w

sudo hwclock --localtime -w

效果等同

sudo timedatectl set-local-rtc 1




hwclock
  • -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
     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.
    
     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.
    
     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或本地时间刻度,但时钟本身没有说明正在使用哪种替代。--localtime--utc选项

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

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

不存在,默认值为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

timedatectl [OPTIONS…] COMMAND …

Query or change system time and date settings.

Commands:
status Show current time settings
show Show properties of systemd-timedated
set-time TIME Set system time
set-timezone ZONE Set system time zone
list-timezones Show known time zones
set-local-rtc BOOL Control whether RTC is in local time 控制RTC是否是本地时间, 1表示是
set-ntp BOOL Enable or disable network time synchronization

systemd-timesyncd Commands:
timesync-status Show status of systemd-timesyncd
show-timesync Show properties of systemd-timesyncd

Options:
-h --help Show this help message
–version Show package version
–no-pager Do not pipe output into a pager
–no-ask-password Do not prompt for password
-H --host=[USER@]HOST Operate on remote host
-M --machine=CONTAINER Operate on local container
–adjust-system-clock Adjust system clock when changing local RTC mode
–monitor Monitor status of systemd-timesyncd
-p --property=NAME Show only properties by this name
-a --all Show all properties, including empty ones
–value When showing properties, only print the value

See the timedatectl(1) man page for details.




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kfepiza

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值