将系统时间设置到硬件时间,设置硬件时区为本地时区
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.