Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Created February 19, 2013 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gene1wood/4988366 to your computer and use it in GitHub Desktop.
Save gene1wood/4988366 to your computer and use it in GitHub Desktop.
Re-implementation of bash wait to do parallel commands. I prefer wait but this is an alternative.
for host in $hostlist; do
scp $filename $host: &
echo "$!" >>$pidlistfile
done
while [ "`wc -l $pidlistfile`" -gt 0 ]; do
for pid in `cat $pidlistfile`; do
if ! kill -0 $pid 2>/dev/null; then
sed -e "/^$pid\$/d" $pidlistfile
fi
done
echo -n "."
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment