From e3e1345aac3d89ec1b6c2603007c8e02305d065a Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 9 Jan 2013 23:00:07 +0100 Subject: [PATCH] parallel: added --sshdelay to slow down ssh logins. --- src/parallel | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parallel b/src/parallel index 17ed9382..02438a3e 100755 --- a/src/parallel +++ b/src/parallel @@ -501,6 +501,7 @@ sub options_hash { "seqreplace=s" => \$opt::seqreplace, "jobs|j=s" => \$opt::P, "delay=f" => \$opt::delay, + "sshdelay=f" => \$opt::sshdelay, "load=s" => \$opt::load, "noswap" => \$opt::noswap, "max-line-length-allowed" => \$opt::max_line_length_allowed, @@ -722,6 +723,10 @@ sub parse_options { wait_and_exit(0); } } + if(not defined $opt::delay) { + # Set --delay to --sshdelay if not set + $opt::delay = $opt::sshdelay; + } if($opt::tollef and not $opt::gnu and not $opt::plain) { # Behave like tollef parallel (from moreutils) $opt::u = 1; @@ -2766,7 +2771,8 @@ sub simultaneous_sshlogin { my $wanted_processes = shift; my $sshcmd = $self->sshcommand(); my $serverlogin = $self->serverlogin(); - my $cmd = "$sshcmd $serverlogin echo simultaneouslogin &1 &"x$wanted_processes; + my $sshdelay = $opt::sshdelay ? "sleep $opt::sshdelay;" : ""; + my $cmd = "$sshdelay$sshcmd $serverlogin echo simultaneouslogin &1 &"x$wanted_processes; ::debug("Trying $wanted_processes logins at $serverlogin"); open (my $simul_fh, "-|", "($cmd)|grep simultaneouslogin | wc -l") or ::die_bug("simultaneouslogin");