zoukankan      html  css  js  c++  java
  • 开发板的时间设置有效,但重启恢复

    使用开发板时,发现RTC的时间总是被设置为2015年11月30日11时30分,无论如何设置,通过hwclock -w或程序修改RTC芯片,修改之后时间和RTC时间均正确,但是断电重启之后,时间又变为2015年11月30日11时30分。

           通过分析和查找发现/etc/目录下的timestamp比较可疑,其值正是113011302015,于是查找包含它的文件有两个,分别为:/etc/init.d目录下的bootmisc.sh和save-rtc.sh。
           其中,bootmisc.sh中有如下内容:
    # Set the system clock from hardware clock
    # If the timestamp is 1 day or more recent than the current time,
    # use the timestamp instead.
    test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
    if test -e /etc/timestamp
    then
    SYSTEMDATE=`date "+%Y%m%d"`
    TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'`
            NEEDUPDATE=`expr ( $TIMESTAMP > $SYSTEMDATE )`
            if [ $NEEDUPDATE -eq 1 ]; then
    date `cat /etc/timestamp`
    /etc/init.d/hwclock.sh stop
    fi
    fi
           上面的脚本会判断文件/etc/timestamp存在与否,且将里面的时间戳与当前系统时间进行比较,如果timestamp的时间比系统时间新1天或以上,则会使用timestamp,并将其写入RTC时间中。
           脚本save-rtc.sh中有如下内容:
    #! /bin/sh
    /etc/init.d/hwclock.sh stop
     
    # Update the timestamp
    date +%2m%2d%2H%2M%Y > /etc/timestamp
           上面的脚本会将当前时间写入timestamp中。
           同时,bootmis.sh脚本被链接到rcS.d中的S55bootmis.sh中,在系统启动时执行,而脚本save-rtc.sh则被链接到rc0.d和rc6.d文件夹中,在系统关闭和重启时执行。
           所以要解决上面的问题,只需:
    1、修改/etc/timestamp,使其小于或等于当前系统时间。
    2、正常关闭或重启系统而不是直接断电。
     
  • 相关阅读:
    Datatables 在asp.net mvc
    VS Code开发调试.NET Core
    领域模型中的用户设计
    MVC数组模型绑定
    Java RMI(远程方法调用) 实例与分析 (转)
    oracle转mysql总结(转)
    Windows远程桌面连接Ubuntu 14.04 (转)
    oracle转Mysql中,varchar2(10)和number应该转换为什么类型? (转)
    MySQL与Oracle的语法区别详细对比 (转)
    python购物淫秽数据分析(2)
  • 原文地址:https://www.cnblogs.com/pengkunfan/p/3843837.html
Copyright © 2011-2022 走看看