NTP服务器
#!/bin/bash #author:dcc #date:2018/05/26 #version:v1 #description:install chrony if [ ! -d "$HOME/mylog" ];then mkdir $HOME/mylog fi config_file="/etc/chrony.conf" log_path="$HOME/mylog/install.log" #check chrony whether install rpm -q chrony >/dev/null if [ ! $? -eq 0 ];then #test yum whether can use? test01=`yum repolist | grep 'repolist: '|sed -n 's/repolist: //p'` if [ "$test01" == "0" ];then echo "error_code:1;the yum.repo can't be used" >> $log_path echo "Error:yum can not be used" exit 1 fi yum -y install chrony > /dev/null && echo "`date`:install chrony success" >> $log_path || echo "`date`:install chrony failed" && exit 1 fi #config chrony sed -ri 's/^(server.*iburst)$/#\1/' $config_file sed -i '/joining the pool/a\ server www.dcc.cn iburst' $config_file #restart and enable chrony systemctl restart chronyd && echo "`date`:restart chronyd success" >> $log_path || echo "`date`:restart chronyd failed,you can use journalctl -xe to check" >> $log_path && exit 2 systemctl enable chronyd && echo "`date`:enable chronyd success" >> $log_path || echo "`date`:enable chronyd failed" >> $log_path && exit 3
NTP服务器