V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
oneforall
V2EX  ›  Linux

请问大佬们 CentOS7 的时间时区问题

  •  
  •   oneforall · Apr 30, 2021 · 2034 views
    This topic created in 1824 days ago, the information mentioned may be changed or developed.
    # timedatectl
    Local time: 六 2021-05-01 03:53:59 CST
    Universal time: 五 2021-04-30 19:53:59 UTC
    RTC time: 五 2021-04-30 19:53:58
    Time zone: Asia/Shanghai (CST, +0800)
    NTP enabled: yes
    NTP synchronized: no
    RTC in local TZ: no
    DST active: n/a

    我的时区确实已经选择上海,感觉 Local time 和 Universal time 反了过来,请问要怎么正确设置?
    7 replies    2021-05-05 16:15:11 +08:00
    ysc3839
        1
    ysc3839  
       Apr 30, 2021 via Android
    没反吧?同步一下时间就好了。
    conanforever22
        2
    conanforever22  
       Apr 30, 2021
    linux 对 bios 里的时间(rtc)是按照 UTC 处理的, 看 timedatectl 的输出应该是 rtc 错了, 重新同步下时间之后 hwclock --systohc 更新 rtc 时间应该就好了
    conanforever22
        3
    conanforever22  
       Apr 30, 2021
    记得之前看过 windows 是把 rtc 当做本地时区处理的, linux 是按照 UTC 处理的, 是不是双系统, windows 发现时间不对然后调了之间之后出现的这种情况
    jousca
        4
    jousca  
       Apr 30, 2021
    如楼上,应该是时间没设置正确。

    UTC 是 19.53 分,你当前时区+8 是 北京时间。变成 5-1 03:53 是对的。

    所以原因就是你时间不正确。不是时区不正确。
    jousca
        5
    jousca  
       Apr 30, 2021
    要看 /etc/sysconfig/clock 里的 UTC 参数,如果 UTC=false,那时区有意义;如果 UTC=true,那时区没意义,实际上是 UTC 时间。
    youdoit
        6
    youdoit  
       May 1, 2021
    删除原来的 rm -rf /etc/localtime,然后做个软连接 ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime,在同步就行了
    root01
        7
    root01  
       May 5, 2021
    timedatectl 命令好使
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5184 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 09:37 · PVG 17:37 · LAX 02:37 · JFK 05:37
    ♥ Do have faith in what you're doing.