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


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

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

    sudo hwclock --localtime -w
    
    • 1

    效果等同

    sudo timedatectl set-local-rtc 1
    
    • 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.
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9

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

    硬件时钟可以配置为使用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.




  • 相关阅读:
    【数据结构】手撕排序算法(上)—— 插入排序(直接插入、希尔) 选择排序(直接选择、堆排序)
    Qt多线程实现方式-moveToThread及其注意事项
    Triton部署mmdeploy导出的TensorRT模型失败篇
    C语言题目要求实现方法总结(1-10)
    Android 内存泄漏分析思路和案例剖析
    CSS 网页布局
    微前端qiankun接入Vue和React项目
    基于STM32F469 discovery kit 开发板的开发2
    周四见|物流人的一周资讯
    Vue2.7 setup 中使用vue-router、vuex
  • 原文地址:https://blog.csdn.net/kfepiza/article/details/127799177