でhoge1でfugaを実行できる.
応用して,以下をbashrcに書いておけば,
ssh_command_broadcast hoge 1 10 fuga
で一気にhoge1〜10でfugaを実行できる
function ssh_command_broadcast(){
hostname=$1
nodeid=$2
endid=$3
shift 3
command=$*
echo ""
echo "*******************************************"
echo "hostname=" ${hostname}`printf "%02d" ${nodeid}` "~" ${hostname}`printf "%02d" ${endid}`
echo "command name=" $command
echo "*******************************************"
echo ""
echo "Are you sure you want to continue ssh (yes/no)?"
read ascert
if [ $ascert = yes ]; then
while [ $nodeid -le $endid ]; do
echo ""
echo ${hostname}`printf "%02d" ${nodeid}`
ssh ${hostname}`printf "%02d" ${nodeid}` $command
nodeid=$((nodeid+1))
done
fi
}
0 件のコメント:
コメントを投稿