- function autossh(){
-
l=0
-
n=0
-
echo "$*" > cachessh.txt
-
a=$(awk -F "$1" '{print $2}' cachessh.txt)
-
for i in $a
-
do
-
echo "$i 执行结果:"
-
ssh $i "$1"
-
if [ $? = 0 ]
-
then
-
let l++
-
else
-
let n++
-
fi
-
done
- }
- autossh "service httpd stop" 192.168.1.2 192.168.1.3 192.168.1.4 1.1.1.1 #$1=>命令 $2=IP
- rm -rf cachessh.txt
- echo "complete 成功$l 失败$n"
转载于:https://my.oschina.net/renqingshigu/blog/681450