Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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