Problems when loop over a series of ssh-ed commands
- by Jack Medley
I have a series of server machines which I want to run the same command on. Each command takes hours and (even though I am running the commands using nohup and setting them to run in the background) I have to wait for each to finish before the next starts. Here is roughly how I have set it up:
On the host machines:
for i in {1..9}; do ssh RemoteMachine${i} ./RunJobs.sh; done
Where RunJobs.sh on each remote machine is:
source ~/.bash_profile
cd AriadneMatching
for file in FileDirectory/Input_*;
do
nohup ./Executable ${file} &
done
exit
Does anyone know of a way such that I dont have to wait for each job to finish before the next starts? Or alternatively a better way of doing this, I have a feeling what I am do is fairly sub-optimal.
Cheers,
Jack