Linux 同步时间脚本

#!/bin/sh

#send hosts to all node

iplist=(
10.130.2.21
10.130.2.22
10.130.2.40
10.130.2.41
10.130.2.42
10.130.2.43
10.130.2.44
10.130.2.45
10.130.2.49
10.130.2.50
10.130.2.51
10.130.2.53
10.130.2.54
10.130.2.55
10.130.2.56
10.130.2.57
10.130.2.58
10.130.2.59
10.130.2.60
10.130.2.62
10.130.2.63
10.130.2.64
10.130.2.65
10.130.2.66
10.130.2.117
10.130.2.118
10.130.2.119
10.130.2.200
10.130.2.201
10.130.2.202
10.130.2.220
10.130.2.240
10.130.2.245
10.130.2.248
10.130.2.249
10.130.3.218
10.130.3.219

)

user=dp

function ntpd()
{
ssh -t -p 22 $host "
sudo service ntpd restart    //重启ntpd服务
sudo ntpdate 10.4.22.240   //与时间服务器同步
sudo chkconfig ntpd on"     //开启ntpd

}

for host in ${iplist[*]};
do

ntpd $host

done

原文地址:https://www.cnblogs.com/sunt9/p/6690379.html