如果配置了ntp服务,同步一下就行了,或者写个脚本在服务器上自动安装ntp服务并同步时间
刚开始学习shell,请大家多指教,没有验证过,楼主就帮忙验证一下吧,肯定需要修改的。
iplist格式是什么啊,假设里面每行是一个ip地址,如果是其他格式,先用awk过滤出来
挑出一台作为first_server,就在这太机器上做,路径自己改
#!/bin/bash
_first_server=·awk -F= '$1 ~ /IPADDR/ {print $2}' /etc/sysconfig/network-scripts/ifcfg-eth0·
while read LINE
do
export $LINE
export ${_first_server}
/usr/bin/expect /home/expect_ssh
done < ip_list.txt
/bin/bash getdate
rm -f date_*.txt
在first_server上建立脚本 expect_ssh
#!/usr/bin/expect
set pass "your_password"
spawn ssh $LINE
expect "(yes/no)?"
send "yes"
expect "*password:"
send "$pass"
spawn date > date_${LINE}.txt
spawn scp date_${LINE}.txt root@$first_server:/home
expect "*assword:"
send "$pass"
interact
exit
在first_server上建立脚本:getdate
#!/bin/bash
for filename in `ls`
do
cat $filename >> date.txt
done
阅读(1895) | 评论(0) | 转发(0) |