more remote_purge_cache.sh(代码来自他人贡献,不知原作者,如有问题,请告知,然后再加上出处) #!/bin/bash cd /usr/local/bin for i in `awk '{print $1}' passwd.txt` do j=`awk -v I="$i" '{if(I==$1)print $2}' passwd.txt` ssh.exp $j $i purge_cache.sh done
more ssh.exp(代码来自他人贡献,不知原作者,如有问题,请告知,然后再加上出处) #!/usr/bin/expect set password [lrange $argv 0 0] set ipaddr [lrange $argv 1 1] set scriptname [lrange $argv 2 2] set arg1 [lrange $argv 3 3] set timeout -1 spawn ssh [email=root@$ipaddr]root@$ipaddr[/email] $scriptname $arg1 match_max 100000 expect "(yes/no)?" { send "yes\r" expect "password:" send "$password\r" } "password:" {send "$password\r"} "*host " {exit 1} interact
more purge_cache.sh
#!/bin/sh /usr/local/varnish/bin/varnishadm -T 127.0.0.1:3500 url.purge *$
more passwd.txt 192.168.0.1 password1
注意:密码文件不能有特殊字符
|
|
|
脚本写好后,执行 purge_cache.sh就可以看见执行效果,而不必登陆每一个服务器进行操作
。
本文转自sery51CTO博客,原文链接: http://blog.51cto.com/sery/163993,如需转载请自行联系原作者