I have a bash script that kicks off multiple rsync processes in parallel. I'd like to limit the number of simultaneous child processes but not serialize the whole script. Here's a simplified version of the current script:#!/bin/bash(  flock -n 200 || exit 0  {    for f in $(ssh $1 ls /var/images/)    do      rsync  &    done    wait  } &> /var/log/my.log) 200>/var/lock/my.lockfileI believe xargs with --max-procs might be a solution but I can't figure out how to integrate that with my script. Can it be done like this, or is there a better way?
Is there a simple way of limiting the number of child processes that execute in parallel?
bash;shell;parallel
ssh $1 find /var/images -type f -print0 |  xargs --null --replace --max-procs=X rsync ${1}:{} /my/destinationShould do the trick.