Subject: Re: psh
To: Christos Zoulas <christos@zoulas.com>
From: dustin sallings <dustin@spy.net>
List: current-users
Date: 10/19/1998 00:11:33
On Mon, 19 Oct 1998, Christos Zoulas wrote:
// What is wrong with:
//
// for i in `cat machinelist`
// do
// ssh -n $i "$@" &
// done
There's no control over how many it'll run. When I've got 1024
machines in machinelinst, it'd require something like 3072-4096 processes
to tell them all to take a new file. With pfor, I tell it to do basically
that, but at most 8 at a time, which will save a *lot* of time, but not
blow the machine up in the meantime.
Also, the syntax gets a bit funny when I have to do that whole
thing in a subshell. Consider a more realistic loop (one that does more
than one thing):
pfor i in 3 5 11 21 8 9 13 7
do
echo sleep $i
sleep $i
echo $i finished
done
I could wrap the whole thing in parens or {}'s to get a subshell,
then background the whole subshell, but it looks a lot funnier than just
throwing a p in front of the for.
BTW, I've replaced the MAXKIDS thing with a normal shell set since
I couldn't figure out how to read local vars cleanly inside of sh itself.
Now, to run 8 simultanous iterations of a loop, you just do this:
set -j8
I used -j because it's the same flag as parallel make, and wasn't
taken.
--
SA, beyond.com The world is watching America,
pub 1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
| Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE
L________________________________________ and America is watching TV. __