V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
phpfpm
V2EX  ›  Linux

我被 sntp 的输出困惑了好久,原来这玩意不是时区

  •  
  •   phpfpm · 32 天前 · 1406 次点击
    这是一个创建于 32 天前的主题,其中的信息可能已经有所发展或是发生改变。
    $ sntp -c 192.168.0.10
    sntp [email protected] (1)
    Can't open KOD db file /var/lib/sntp/kod for writing: Permission denied
    2025-02-28 16:31:12.839708 (-0800) +0.0 +/- 0.014694 192.168.0.10 s1 no-leap
    
    
    

    我就真的一直很困惑,为啥我的日期时间时区都是对的,给我的结果的时区显示的是-0800 呢?

    看了下文档:

    The default is to write the estimated correct local date and time (i.e. not UTC) to the standard output in a format like: '1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP sN' where the '(+0800)' means that to get to UTC from the reported local time one must add 8 hours and 0 minutes,
    

    彳亍。

    +8000 是说你看到的时间再加上 8 个小时是 UTC (实际上是 UTC-8 的西八区)

    东八区当然显示-0800 了

    做个实验,带上其他 TZ 执行 sntp:

    $ TZ=UTC sntp -c 192.168.0.10
    sntp [email protected] (1)
    Can't open KOD db file /var/lib/sntp/kod for writing: Permission denied
    2025-02-28 08:33:22.297831 (+0000) +0.0 +/- 0.011989 192.168.0.10 s1 no-leap
    
    

    这就对了嘛

    2 条回复    2025-03-02 23:20:59 +08:00
    Belmode
        1
    Belmode  
       30 天前
    你认真的吗
    phpfpm
        2
    phpfpm  
    OP
       30 天前
    @Belmode 哪里不认真了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1129 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 18:31 · PVG 02:31 · LAX 11:31 · JFK 14:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.