SSH to multiple hosts at once -
i have script loops through list of hosts, connecting each of them ssh using rsa key, , saving output file on local machine - works correctly. however, commands run on each server take while (~30 minutes) , there 10 servers. run commands in parallel save time, can't seem working. here code (working):
for host in $hosts; echo "connecting $host".. ssh -n -t -t $user@$host "/data/reports/formatted_report.sh" done
how can speed up?
you should add &
end of ssh call, run on background.
for host in $hosts; echo "connecting $host".. ssh -n -t -t $user@$host "/data/reports/formatted_report.sh" & done
Comments
Post a Comment