Shell实现系统时间和BIOS时间同步校准脚本分享
该脚本主要是从定义好的NTP服务器列表获取服务器地址进行同步,如果第一个不成功,会继续换下一个地址进行同步!不完善之处还请指出!
#!/bin/bash #NTP网络时间校正脚本 #奔跑
#NTP服务器数组列表 ntpServer=(
[0]=ntp.fudan.edu.cn [1]=asia.pool.ntp.org [2]=210.72.145.44 [3]=133.100.11.8 [4]=ntp.sjtu.edu.cn [5]=time.scau.edu.cn
)
#校验# serverNum=`echo${#ntpServer[*]}` NUM=0 for((i=0;i<=$serverNum;i++));do echo-n"正在和NTP服务器${ntpServer[$NUM]}校验中..." /usr/sbin/ntpdate${ntpServer[$NUM]}>>/dev/null2>&1 if[$?-eq0];then echo-e"\e[1;32m\t\t\t\t\t[成功]\e[0m" break else echo-e"\e[1;31m\t\t\t\t\t[失败]\e[0m" letNUM++ fi sleep2
done
#设置BIOS时间和系统时间一致 hwclock--systohc
热门推荐
10 小学毕业父母简短祝福语
11 幼儿生日祝福语模板简短
12 新娘妈妈的祝福语简短
13 邻居聚会祝福语大全简短
14 十条祝福语简短
15 给同学祝福语的简短
16 过年祝福语简短祝妈妈
17 祝女儿简短祝福语大全
18 恩师诗词祝福语简短大全