Question

I'm trying to run a script on multiple remote servers, with multiple parameters. The GNU parallel command is:

parallel --onall -S ${RH32},{RH64} /shared/loc/script.sh ::: param1 param2

script.sh:

host=`uname -n`
param=$1
logfile=/shared/loc/log-$host-$param
for i in `seq 1 5`; do
    touch ${logfile}_$i
    sleep 2
done

I'm trying to achieve a run on 4 processes in parallel:

  • rh32 running script.sh with param1
  • rh32 running script.sh with param2
  • rh64 running script.sh with param1
  • rh64 running script.sh with param2

When looking at the output as it accumulates it appears that what really happens is this:

  • rh32 running script.sh with param1
  • rh64 running script.sh with param1

-are being run in in parallel. When they finish, the other two are being run in parallel.

How can I make all four of them run in parallel at the same time?

Thanks,

Was it helpful?

Solution

You are hitting a design decision: What does -j mean when you run --onall? The decision is that -j is the number of hosts to run on simultaneously (in your case 2). This was done so that it would be easy to run commands serially on a number of hosts in parallel.

What you can do, is wrap your parallel command with another parallel command:

parallel parallel --onall -S ${RH32},${RH64} --argsep // /shared/loc/script.sh // ::: param1 param2

This will spawn parallel for each argument and the inner parallel will spawn for each server.

Another solution is to write the ssh command yourself:

parallel ssh {1} /shared/loc/script.sh {2} ::: ${RH32} ${RH64} ::: param1 param2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top