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

遇到一个 openwrt 上古怪的时间同步的问题,请各位帮忙看看。

  •  
  •   windhunter · 2014-05-13 10:38:53 +08:00 · 12602 次点击
    这是一个创建于 3629 天前的主题,其中的信息可能已经有所发展或是发生改变。
    遇到一个时间同步问题。请看图:


    右边是windows正确的时间,左边是openwrt获取的错误时间。
    古怪的是,和正确的时间差距74682秒.

    如图所示,openwrt上时区设置是正确的,
    并且,ntpd从asia.pool.ntp.org获取时间是不太可能有错的。

    实在没想通74682这个神奇的数字从何而来.
    15 条回复    2015-04-16 09:54:14 +08:00
    Tink
        1
    Tink  
       2014-05-13 10:58:32 +08:00 via iPhone
    一个CST,一个UTC啊
    windhunter
        2
    windhunter  
    OP
       2014-05-13 11:56:30 +08:00
    感谢回复。
    坦白讲,我知道一个是cst一个是utc。
    http://wiki.openwrt.org/doc/uci/system 上,已经清楚的写明 Asia/Shanghai CST-8
    http://zh.wikipedia.org/wiki/UTC%2B8 上,也清楚的写明 uct+8 就是“中国大陆-北京时间”
    所以我认为,这是一回事。
    我实在弄不清楚的是,时差最多24小时。我发帖子的时候明明是2014年5月13日,但ntp更新过来的时间居然是2014年5月10日。继续百思不得其解中....
    skydiver
        3
    skydiver  
       2014-05-13 12:55:43 +08:00
    @windhunter 先把时间改对再同步吧。。时间差的太多ntp同步不了。
    thekll
        4
    thekll  
       2014-05-13 12:59:40 +08:00
    @windhunter
    好像时间没有同步成功
    windhunter
        5
    windhunter  
    OP
       2014-05-13 13:35:57 +08:00
    是这样的,我这个刷了openwrt的路由器并没有内部电池。
    启动后如果不联网的话,根本无法正确校准时间。
    也就是说,路由器不能正常连接internet的话,启动后,其时间一定是1970-01-01
    从目前的表现来看,时间已经被ntp同步过,但同步的结果不对.
    我实在是找不到同步失败的原因.
    tempdban
        6
    tempdban  
       2014-05-13 13:36:34 +08:00 via Android
    ntpd是平滑同步 想立即同步 请ntpdate
    tempdban
        7
    tempdban  
       2014-05-13 13:37:08 +08:00 via Android
    nanpuyue
        8
    nanpuyue  
       2014-05-13 14:55:38 +08:00
    没有内部电池但是有内部存储,即使是刚刷好的路由器其时间也不会是1970-01-1。
    所以,同步失败才是真正的原因,ntp同步神马的失败是常有的事情。
    usedname
        9
    usedname  
       2014-05-13 15:07:05 +08:00
    是不是用了什么夏令时
    standin000
        10
    standin000  
       2014-05-13 15:46:15 +08:00
    试试 ntpd -q -n -d -p ntp.api.bz
    vmebeh
        11
    vmebeh  
       2014-05-13 17:32:06 +08:00   ❤️ 2
    root@OpenWrt:~# cat /etc/TZ
    HKT-8
    root@OpenWrt:~# cat /etc/config/system

    config system
    option hostname 'OpenWrt'
    option zonename 'Asia/Hong Kong'
    option timezone 'HKT-8'
    option conloglevel '8'
    option cronloglevel '8'

    config timeserver 'ntp'
    list server '0.openwrt.pool.ntp.org'
    list server '1.openwrt.pool.ntp.org'
    list server '2.openwrt.pool.ntp.org'
    list server '3.openwrt.pool.ntp.org'

    我的是这样的,可以正常同步时间
    julyclyde
        12
    julyclyde  
       2014-05-13 17:49:27 +08:00
    UTC+8和China Standard Time完全是两个概念……只是在目前阶段,二者的数值一致而已

    先手工强制同步一下,然后ntpd负责保持
    caizixian
        13
    caizixian  
       2014-05-13 22:10:28 +08:00
    sudo ntpdate time.nist.gov
    brightsm
        14
    brightsm  
       2014-12-16 14:05:19 +08:00
    vmebeh说的没错。
    Tonni
        15
    Tonni  
       2015-04-16 09:54:14 +08:00
    @vmebeh 谢谢,亲测有效
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4749 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:52 · PVG 17:52 · LAX 02:52 · JFK 05:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.