#!/usr/bin/expect
set timeout 5
set password leadtone
set file [open iplist r]
set n 0
while { [ gets $file host ] >= 0 } {
incr n
spawn ssh $host
expect {
"(yes/no)?" {
send "yes\n"
expect "password: "
send "$password\n"
}
"password: " {
send "$password\n"
}
}
sleep 1
send "echo > /var/log/maillog\r"
send "echo > /var/podo/log/dovecot-info.log\r"
send "echo > /var/podo/log/dovecot.log\r"
sleep 1
}
exit
close $file
在本目录下建一个iplist文件,把需要清空的服务器IP写入保存,运行 expect del_log.sh