时间对时:
all_host.txt 参考 pssh 的参数来写
下载这个 https://github.com/angeloc/htpdate 并且解压到 cd /root/htpdate-1.2.6
prsync -h all_host.txt /root/htpdate-1.2.6/ /root/htpdate-1.2.6/
pssh -h all_host.txt 'timedatectl set-local-rtc 0'
pssh -h all_host.txt 'systemctl stop ntpd'
pssh -h all_host.txt 'systemctl disable ntpd'
pssh -h all_host.txt 'yum remove -y ntpdate'
pssh -h all_host.txt 'timedatectl set-timezone Asia/Shanghai' pssh -h all_host.txt 'cd /root/htpdate-1.2.6 && make ENABLE_HTTPS=1 && make install'
pssh -h all_host.txt 'htpdate -a -t http://www.baidu.com && hwclock -w'
pssh -P -h all_host.txt 'htpdate -a -t http://www.baidu.com && hwclock -w && date' | grep -v root | grep -v correction
编辑跳板机: /root/time.sh
cDate=$(wget http://www.baidu.com --debug -o /tmp/time.html && cat /tmp/time.html | grep Date | head -n 1)
cDate=${cDate/Date:/}
echo $cDate
date -s "$cDate"
hwclock -w
prsync -h all_host.txt /root/time.sh /root/time.sh
pssh -h all_host.txt 'bash /root/time.sh'
pssh -h all_host.txt 'htpdate -a -t http://www.baidu.com && hwclock -w' pssh -P -h all_host.txt 'date' | grep -v root
增加定时任务
0 4 * * * root parallel-ssh -h /root/all_host.txt 'bash /root/time.sh'
0 4 * * * root parallel-ssh -h /root/all_host.txt 'htpdate -a -t http://www.baidu.com && hwclock -w'