Problems when loop over a series of ssh-ed commands

Posted by Jack Medley on Super User See other posts from Super User or by Jack Medley
Published on 2013-10-20T21:35:08Z Indexed on 2013/10/20 21:57 UTC
Read the original article Hit count: 226

Filed under:
|
|

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

© Super User or respective owner

Related posts about bash

Related posts about ssh