更新系统时间,并写入硬件时间里
-
查看是否安装ntpdate工具
-
创建上海时区文件的软链接
-
更新时间并写入到硬件时间里
#!/bin/bash package="ntpdate" info=$(rpm -q ${package}) check_pkgs(){ if [ ! -e ${info} ] then echo "ntpdate already exists!" else echo "start installation!" yum clean all > /dev/null 2>&1 fi yum update -y && yum install -y ${package} > /dev/null 2>&1 fi } modify_time(){ echo "开始修改时间" rm -rf /etc/localtime && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime /usr/sbin/ntpdate cn.pool.ntp.org > /dev/null 2>&1 && hwclock -w } check_pkgs modify_time

浙公网安备 33010602011771号