新路程------shell之hi3516 rtc同步
来源:互联网 发布:手机网络的图标怎么换 编辑:程序博客网 时间:2024/05/06 20:13
昨天搞了网络时间同步到系统,现在要把系统时间同步到网络,hi3516a的rtc没有建立/dev/misc/rtc这个节点,所以通常的hwclock -w无法使用,没辙,只能自己搞个脚本写时间到rtc中
#!/bin/sh
readdate()
{
x=` date `
echo $x
i=0
OLD_IFS="$IFS"
IFS=" "
arr=$x
IFS="$OLD_IFS"
for s in $arr
do
let i+=1;
case $i in
2)
case $s in
Jan)
mouth=1
;;
Feb)
mouth=2
;;
Mar)
mouth=3
;;
Apr)
mouth=4
;;
May)
mouth=5
;;
Jun)
mouth=6
;;
Jul)
mouth=7
;;
Aug)
mouth=8
;;
Sep)
mouth=9
;;
Oct)
mouth=10
;;
Nov)
mouth=11
;;
Dec)
mouth=12
;;
esac
;;
3)
day=$s
;;
4)
hourold=$s
hournew=${hourold//':'/'/'}
;;
6)
year=$s
;;
esac
done
timenow=${year}"/"${mouth}"/"${day}"/"${hournew}
echo $timenow
}
writertc()
{
echo "writertc"
/usr/rtc_test -s time $timenow
/usr/rtc_test -g time
}
while true
do
ntpdate time 120.25.108.11
if [ $? -eq 0 ];then
readdate
writertc
else
echo "ntpdate time 120.25.108.11 failed,120.25.108.11 not suitable"
ntpdate time 202.108.6.95
if [ $? -eq 0 ];then
readdate
writertc
else
echo "ntpdate time 120.25.108.11 failed,202.108.6.95 not suitable ,sync time failed"
fi
fi
sleep 30
done
然后到/etc/init.d/S81service里加个守护进程
#!/bin/sh
start-stop-daemon --start --quiet --background --exec /usr/start.sh
start-stop-daemon --start --quiet --background --exec /usr/ntp_service.sh
- 新路程------shell之hi3516 rtc同步
- 新路程------hi3516 tmp过小导致更新img失败
- 新路程------rtc bq32002的porting
- 新路程------hi3516a 内置rtc调试
- 新方向,新路程
- 新的路程
- 新路程------从零开始git
- 新路程------平时小心
- 新路程------hi3516a watchdog
- 铺展新一天的路程
- swift3新路程(3)"\()"
- 新路程------imx6 lvds ioctl
- 新路程------telnet调试linux
- 新路程------hi3516a kernel启动
- 新路程------GDB 调试(1)
- 新路程------imx6关闭屏保
- 新路程------eclipse加库
- 新路程------hi3516a phy初始化
- errre
- redis4.0之Lua脚本新姿势
- nexus-3.5.1-02 windows 安装
- HTML & CSSJava & Javascript——扶朕起来,朕还能接着编!
- 九月总结:结束两年左右的工作有感
- 新路程------shell之hi3516 rtc同步
- linux下直接修改压缩包中的内容
- unity中的简单延时方法
- Nodejs 读取中文时乱码问题
- 闭包 arguments 属性的使用(闭包)
- 那些年使用Android Studio碰上的那些事儿
- java单元测试工具 junit
- UVA 10161
- Kotlin笔记一