I need to automate the execution of several scripts, and I'm writing a script.

The scripts have to run concurrently because they are part of a benchmarking suite.

I'm trying to execute 6 different scripts on two different machines through the following script:


(cd /opt/scripts
sudo sh runp.sh)

(cd /opt/scripts
sudo sh runt.sh)

(cd /opt/scripts
sudo sh rund.sh)

(echo "iniciando slave remoto"
ssh sut@slave <<'ENDSSH'
cd /opt/scripts
sudo sh runs.sh

(ssh sut@slave <<'ENDSSH'
/home/sut/pf/server-sysfs 8989

(cd /opt/scripts
sudo sh runc.sh)

but it blocks on the 3rd script and the echo message doesn't show on screen.

Any hint or help on how can I approach it will be very appreciated.

P.S. I have 0 bash scripting experience, so maybe my approach isn't even remotely right.


Try this way:


sudo sh /opt/scripts/runp.sh &
sudo sh /opt/scripts/runt.sh &
sudo sh /opt/scripts/rund.sh &

ssh sut@slave sudo sh /opt/scripts/runs.sh &
ssh sut@slave /home/sut/pf/server-sysfs 8989 &

sudo sh /opt/scripts/runc.sh &
  • Thank you @jherran for your answer but it appears as if the ssh scripts weren't runing. – daviziko Nov 27 '14 at 15:17
  • If you can connect with ssh sut@slave, should do. Anyway, you could append nohup before the first ssh command and run again. This will generate a file called nohup.out that you must check to see the results of the command. Do not append nohup to both ssh command, because last one overwrite the output of first one. – jherran Nov 27 '14 at 15:25
  • your solution "works" in theory, but the scripts execute programs that make extensive use of working directory and that's becoming a pain in the ass. – daviziko Nov 27 '14 at 17:19
  • You want an script to run six parallels process and you got it. If the six scripts executed by this script make extensive use of working directory, that another problem I suppose, and you have to look after it or ask another question. – jherran Nov 27 '14 at 17:30
  • Thank you again, I finally got it working mixing your answer with the parenthesis thing. – daviziko Nov 27 '14 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.