I have a shell script that initiates a long, resource-intensive command on several different machines.
In order to execute the script on each machine in parallel, I have an ampersand symbol after each remote command in the for-loop.
while read host; do ssh -f "$host" \"/home/user/allocate.sh\" & done < ~/cluster
However, as a consequence, I do not get the shell prompt back at the end of the for-loop.
This prevents me from executing other scripts after
initialize-cluster.sh has finished running
allocate.sh on all of the machines.
For example, I want to be able to run a command such as:
./initalize-cluster.sh && ./execute-something-else.sh
initialize-cluster never "finishes."
I'd like subsequent commands to execute only after all of the
allocate.sh scripts finish on the remote machines.