Oded Arbel wrote:

Hi List.

I'm using ssh -f to background ssh so I can run the same operation
on multiple machines in parallel

for server in 1 2 ...; do ssh -f [EMAIL PROTECTED] 'run maintenance task'
    pids="$pids $(getSSHpid)"
done

while kill -0 $pids 2>/dev/null; do echo "Waiting.."; sleep 1; done

Havn't checked it, but:
for server in 1 2 ...
do
      ssh [EMAIL PROTECTED] 'run maintenance task' &
done

for process in `seq 1 numservers`
do
      wait %$process
done

should work.

In particular, running ssh with -f means that it backgrounds itself, and thus the shell does not keep track over its process number. On the other hand, running with & (assuming you don't need to put in a password) means that %1, %2 etc. translate to the processes the shell launched. The above script (maybe with slightly different syntax) should launch all jobs concurrently, and exit only after the last of the jobs has exited.

Shachar

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to