#!/bin/bash
#使用方法 ./test.sh host1 host2
#注意,此处前提已经配置了ssh免登陆
#此程序规定了同时后台运行的程序个数为thread=2
host=$@
echo $host
function a_sub(){
sleep 3;
echo "Runing:ssh $1 \"date\""
ssh -n $1 "date"
}
tmp_fifofile="/tmp/$$.fifo"
mkfifo $tmp_fifofile
exec 6<>$tmp_fifofile
rm $tmp_fifofile
thread=2
for ((i=0;i<$thread;i++));do
echo
done>&6
for node in $host;do
read -u6
{
a_sub $node && {
echo "date on $node is finished"
}||{
echo "error"
}
echo >&6
}&
done
wait
exec 6>&-
exit 0
Latest posts by Zhiming Zhang (see all)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021