mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +00:00
Look for options in ~/.parallelrc and $PARALLEL
This commit is contained in:
parent
e99bdb0b82
commit
fee1dae246
9
README
9
README
|
@ -5,10 +5,11 @@ Please send problems and feedback to bug-parallel@gnu.org.
|
||||||
|
|
||||||
= Presentation of GNU Parallel =
|
= Presentation of GNU Parallel =
|
||||||
|
|
||||||
GNU Parallel is a shell tool for executing jobs in parallel. A job is
|
GNU Parallel is a shell tool for executing jobs in parallel using one
|
||||||
typically a single command or a small script that has to be run for
|
or more machines. A job is typically a single command or a small
|
||||||
each of the lines in the input. The typical input is a list of files,
|
script that has to be run for each of the lines in the input. The
|
||||||
a list of hosts, a list of users, or a list of tables.
|
typical input is a list of files, a list of hosts, a list of users, or
|
||||||
|
a list of tables.
|
||||||
|
|
||||||
If you use xargs today you will find GNU Parallel very easy to use. If
|
If you use xargs today you will find GNU Parallel very easy to use. If
|
||||||
you write loops in shell, you will find GNU Parallel may be able to
|
you write loops in shell, you will find GNU Parallel may be able to
|
||||||
|
|
69
src/parallel
69
src/parallel
|
@ -10,10 +10,11 @@ B<parallel> [options] [I<command> [arguments]] [< list_of_arguments]
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
GNU B<parallel> is a shell tool for executing jobs in parallel. A job
|
GNU B<parallel> is a shell tool for executing jobs in parallel using
|
||||||
is typically a single command or a small script that has to be run for
|
one or more machines. A job is typically a single command or a small
|
||||||
each of the lines in the input. The typical input is a list of files,
|
script that has to be run for each of the lines in the input. The
|
||||||
a list of hosts, a list of users, a list of URLs, or a list of tables.
|
typical input is a list of files, a list of hosts, a list of users, a
|
||||||
|
list of URLs, or a list of tables.
|
||||||
|
|
||||||
If you use B<xargs> today you will find GNU B<parallel> very easy to
|
If you use B<xargs> today you will find GNU B<parallel> very easy to
|
||||||
use as GNU B<parallel> is written to have the same options as
|
use as GNU B<parallel> is written to have the same options as
|
||||||
|
@ -1140,6 +1141,40 @@ B<seq 1 19 | parallel -j+0 buffon -o - | sort -n >>B< result>
|
||||||
B<cat files | parallel -j+0 cmd>
|
B<cat files | parallel -j+0 cmd>
|
||||||
|
|
||||||
|
|
||||||
|
=head1 ENVIRONMENT VARIABLES
|
||||||
|
|
||||||
|
The environment variable $PARALLEL will be used as default options for
|
||||||
|
GNU B<parallel>. However, because some options take arguments the
|
||||||
|
options need to be split into groups in which only the last option
|
||||||
|
takes an argument. Each group of options should be put on a line of its
|
||||||
|
own.
|
||||||
|
|
||||||
|
=head1 INIT FILE (RC FILE)
|
||||||
|
|
||||||
|
The file ~/.parallelrc will be read if it exists. It should be
|
||||||
|
formatted like the environment variable $PARALLEL. Lines starting with
|
||||||
|
'#' will be ignored.
|
||||||
|
|
||||||
|
|
||||||
|
=head2 EXAMPLE
|
||||||
|
|
||||||
|
cat list | parallel -j1 -k -v ls
|
||||||
|
|
||||||
|
can be written as:
|
||||||
|
|
||||||
|
cat list | PARALLEL="-kvj1" parallel ls
|
||||||
|
|
||||||
|
cat list | parallel -j1 -k -v -S"myssh user@server" ls
|
||||||
|
|
||||||
|
can be written as:
|
||||||
|
|
||||||
|
cat list | PARALLEL="-kvj1
|
||||||
|
-Smyssh user@server" parallel echo
|
||||||
|
|
||||||
|
Notice the newline in the middel is needed because both B<-S> and
|
||||||
|
B<-j> take an argument and thus both need to be at the end of a group.
|
||||||
|
|
||||||
|
|
||||||
=head1 BUGS
|
=head1 BUGS
|
||||||
|
|
||||||
Filenames beginning with '-' can cause some commands to give
|
Filenames beginning with '-' can cause some commands to give
|
||||||
|
@ -1320,6 +1355,19 @@ sub parse_options {
|
||||||
$Global::default_simultaneous_sshlogins = 9;
|
$Global::default_simultaneous_sshlogins = 9;
|
||||||
|
|
||||||
Getopt::Long::Configure ("bundling","require_order");
|
Getopt::Long::Configure ("bundling","require_order");
|
||||||
|
# Add options from .parallelrc
|
||||||
|
my $parallelrc = $ENV{'HOME'}."/.parallelrc";
|
||||||
|
if(-r $parallelrc) {
|
||||||
|
open (IN, "<", $parallelrc) || die;
|
||||||
|
while(<IN>) {
|
||||||
|
/^\s*\#/ and next;
|
||||||
|
chomp;
|
||||||
|
unshift @ARGV, $_;
|
||||||
|
}
|
||||||
|
close IN;
|
||||||
|
}
|
||||||
|
# Add options from shell variable $PARALLEL
|
||||||
|
$ENV{'PARALLEL'} and unshift @ARGV, split/\n/, $ENV{'PARALLEL'};
|
||||||
GetOptions("debug|D" => \$::opt_D,
|
GetOptions("debug|D" => \$::opt_D,
|
||||||
"xargs|m" => \$::opt_m,
|
"xargs|m" => \$::opt_m,
|
||||||
"X" => \$::opt_X,
|
"X" => \$::opt_X,
|
||||||
|
@ -1518,9 +1566,14 @@ sub generate_command_line {
|
||||||
} else {
|
} else {
|
||||||
# append args
|
# append args
|
||||||
my $arg=join(" ",@quoted_args);
|
my $arg=join(" ",@quoted_args);
|
||||||
$job_line .= " $arg";
|
if($job_line) {
|
||||||
|
$job_line .= " ".$arg;
|
||||||
|
} else {
|
||||||
|
# Parallel behaving like '|sh'
|
||||||
|
$job_line = $arg;
|
||||||
}
|
}
|
||||||
debug("Return jobline: $job_line\n");
|
}
|
||||||
|
debug("Return jobline: !$job_line!\n");
|
||||||
}
|
}
|
||||||
return ($job_line,\@quoted_args);
|
return ($job_line,\@quoted_args);
|
||||||
}
|
}
|
||||||
|
@ -2146,7 +2199,7 @@ sub get_next_arg {
|
||||||
$arg = shell_quote($arg);
|
$arg = shell_quote($arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug("Next arg: ".$arg."\n");
|
debug("Next arg: !".$arg."!\n");
|
||||||
return $arg;
|
return $arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2615,7 +2668,7 @@ $Global::control_path = 0;
|
||||||
# TODO --max-number-of-jobs print the system limited number of jobs
|
# TODO --max-number-of-jobs print the system limited number of jobs
|
||||||
|
|
||||||
# TODO Debian package
|
# TODO Debian package
|
||||||
# TODO environment variable and .parallelrc
|
# TODO transfer a script to be run
|
||||||
|
|
||||||
#=item B<--sshlogin> I<[ncpu/]sshlogin[,[ncpu/]sshlogin[,...]]> (beta testing)
|
#=item B<--sshlogin> I<[ncpu/]sshlogin[,[ncpu/]sshlogin[,...]]> (beta testing)
|
||||||
# Skilletegn:
|
# Skilletegn:
|
||||||
|
|
11
unittest/actual-results/test21
Normal file
11
unittest/actual-results/test21
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
### Test $PARALLEL
|
||||||
|
1
|
||||||
|
ssh -l parallel parallel-server2 echo\ 1;
|
||||||
|
1
|
||||||
|
ssh parallel-server1 echo\ 2;
|
||||||
|
2
|
||||||
|
### Test ~/.parallelrc
|
||||||
|
ssh -l parallel parallel-server2 echo\ 1;
|
||||||
|
1
|
||||||
|
ssh parallel-server1 echo\ 2;
|
||||||
|
2
|
18
unittest/tests-to-run/test21.sh
Normal file
18
unittest/tests-to-run/test21.sh
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PAR=parallel
|
||||||
|
SERVER1=parallel-server1
|
||||||
|
SERVER2=parallel-server2
|
||||||
|
|
||||||
|
echo '### Test $PARALLEL'
|
||||||
|
echo | PARALLEL=--number-of-cpus $PAR
|
||||||
|
seq 1 2 | PARALLEL="-S$SERVER1
|
||||||
|
-Sssh -l parallel $SERVER2
|
||||||
|
-j1" $PAR -kv echo
|
||||||
|
|
||||||
|
echo '### Test ~/.parallelrc'
|
||||||
|
echo "-S$SERVER1
|
||||||
|
-Sssh -l parallel $SERVER2
|
||||||
|
-j1" > ~/.parallelrc
|
||||||
|
seq 1 2 | $PAR -kv echo
|
||||||
|
rm ~/.parallelrc
|
11
unittest/wanted-results/test21
Normal file
11
unittest/wanted-results/test21
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
### Test $PARALLEL
|
||||||
|
1
|
||||||
|
ssh -l parallel parallel-server2 echo\ 1;
|
||||||
|
1
|
||||||
|
ssh parallel-server1 echo\ 2;
|
||||||
|
2
|
||||||
|
### Test ~/.parallelrc
|
||||||
|
ssh -l parallel parallel-server2 echo\ 1;
|
||||||
|
1
|
||||||
|
ssh parallel-server1 echo\ 2;
|
||||||
|
2
|
Loading…
Reference in a new issue