#!/bin/bash
##设置中国时区

sudo  cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cat >/etc/sysconfig/clock <<EOF
ZONE="Asia/Shanghai"
UTC=false
ARC=false

EOF

##添加时间同步计划
yum install -y ntpdate
ntp_cron=`cat /etc/crontab |grep ntpdate |grep -v grep |wc -l`

if [ $ntp_cron == 0 ];then
        echo "10 5 * * * root /usr/sbin/ntpdate timekeeper.isi.edu && /sbin/hwclock -w" >>/etc/crontab
else
    echo "Already has the cron"

fi

cat /etc/crontab

date
