my @childs; my @allfolders => List of all folders for ( my $i=0; $i<@allFolders; $i+=5 ) { my @sourceFolders = @allFolders[$i..$i+4]; foreach my $folders ( @sourceFolders ) { my $pid = fork(); if ( $pid ) { # parent push(@childs, $pid); } elsif ($pid == 0) { EXECUTe RSYNC HERE.... } else { print "Error: Cannot fork process : $! \n",1); } } foreach ( @childs ) { waitpid($_, 0); } }