2010-12-06 23:30:08 +00:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
2014-07-26 11:17:13 +00:00
|
|
|
=encoding utf8
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
parallel - build and execute shell command lines from standard input in parallel
|
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
B<parallel> [options] [I<command> [arguments]] < list_of_arguments
|
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
B<parallel> [options] [I<command> [arguments]] ( B<:::> arguments | B<:::+> arguments |
|
|
|
|
B<::::> argfile(s) | B<::::+> argfile(s) ) ...
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
B<parallel> --semaphore [options] I<command>
|
|
|
|
|
|
|
|
B<#!/usr/bin/parallel> --shebang [options] [I<command> [arguments]]
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
B<#!/usr/bin/parallel> --shebang-wrap [options] [I<command> [arguments]]
|
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
2017-01-01 11:42:52 +00:00
|
|
|
STOP!
|
|
|
|
|
|
|
|
Read the B<Reader's guide> below if you are new to GNU B<parallel>.
|
|
|
|
|
2011-12-21 23:17:49 +00:00
|
|
|
GNU B<parallel> is a shell tool for executing jobs in parallel using
|
2012-03-12 22:38:38 +00:00
|
|
|
one or more computers. A job can be a single command or a small
|
2011-12-21 23:17:49 +00:00
|
|
|
script that has to be run for each of the lines in the input. The
|
|
|
|
typical input is a list of files, a list of hosts, a list of users, a
|
|
|
|
list of URLs, or a list of tables. A job can also be a command that
|
|
|
|
reads from a pipe. GNU B<parallel> can then split the input into
|
|
|
|
blocks and pipe a block into each command in parallel.
|
2011-03-20 21:40:12 +00:00
|
|
|
|
|
|
|
If you use xargs and tee today you will find GNU B<parallel> very easy to
|
|
|
|
use as GNU B<parallel> is written to have the same options as xargs. If
|
|
|
|
you write loops in shell, you will find GNU B<parallel> may be able to
|
|
|
|
replace most of the loops and make them run faster by running several
|
|
|
|
jobs in parallel.
|
|
|
|
|
|
|
|
GNU B<parallel> makes sure output from the commands is the same output as
|
|
|
|
you would get had you run the commands sequentially. This makes it
|
|
|
|
possible to use output from GNU B<parallel> as input for other programs.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
For each line of input GNU B<parallel> will execute I<command> with
|
|
|
|
the line as arguments. If no I<command> is given, the line of input is
|
|
|
|
executed. Several lines will be run in parallel. GNU B<parallel> can
|
|
|
|
often be used as a substitute for B<xargs> or B<cat | bash>.
|
|
|
|
|
2011-07-25 22:12:46 +00:00
|
|
|
=head2 Reader's guide
|
|
|
|
|
2014-01-04 07:11:02 +00:00
|
|
|
Start by watching the intro videos for a quick introduction:
|
2011-11-22 21:52:52 +00:00
|
|
|
http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2017-01-01 11:42:52 +00:00
|
|
|
Then look at the B<EXAMPLE>s after the list of B<OPTIONS> (Use
|
|
|
|
B<LESS=+/EXAMPLE\: man parallel>). That will give you an idea of what
|
|
|
|
GNU B<parallel> is capable of.
|
2014-01-04 07:11:02 +00:00
|
|
|
|
|
|
|
Then spend an hour walking through the tutorial (B<man
|
|
|
|
parallel_tutorial>). Your command line will love you for it.
|
|
|
|
|
|
|
|
Finally you may want to look at the rest of this manual if you have
|
|
|
|
special needs not already covered.
|
|
|
|
|
2015-02-01 13:38:26 +00:00
|
|
|
If you want to know the design decisions behind GNU B<parallel>, try:
|
|
|
|
B<man parallel_design>. This is also a good intro if you intend to
|
|
|
|
change GNU B<parallel>.
|
|
|
|
|
2014-01-04 07:11:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 OPTIONS
|
|
|
|
|
|
|
|
=over 9
|
|
|
|
|
|
|
|
=item I<command>
|
|
|
|
|
|
|
|
Command to execute. If I<command> or the following arguments contain
|
2011-07-18 16:29:37 +00:00
|
|
|
replacement strings (such as B<{}>) every instance will be substituted
|
|
|
|
with the input.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2012-03-15 20:23:53 +00:00
|
|
|
If I<command> is given, GNU B<parallel> solve the same tasks as
|
|
|
|
B<xargs>. If I<command> is not given GNU B<parallel> will behave
|
|
|
|
similar to B<cat | sh>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2012-02-20 00:48:28 +00:00
|
|
|
The I<command> must be an executable, a script, a composed command, or
|
2014-03-31 19:29:47 +00:00
|
|
|
a function.
|
|
|
|
|
2016-03-22 19:09:18 +00:00
|
|
|
B<Bash functions>: B<export -f> the function first or use B<env_parallel>.
|
|
|
|
|
|
|
|
B<Bash aliases>: Use B<env_parallel>.
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
B<Csh aliases>: Use B<env_parallel>.
|
|
|
|
|
|
|
|
B<Tcsh aliases>: Use B<env_parallel>.
|
2016-03-22 19:09:18 +00:00
|
|
|
|
2016-09-04 08:42:04 +00:00
|
|
|
B<Zsh functions and aliases>: Use B<env_parallel>.
|
2016-03-22 19:09:18 +00:00
|
|
|
|
|
|
|
B<Fish functions and aliases>: Use B<env_parallel>.
|
|
|
|
|
|
|
|
B<Ksh functions and aliases>: Use B<env_parallel>.
|
|
|
|
|
|
|
|
B<Pdksh functions and aliases>: Use B<env_parallel>.
|
|
|
|
|
2014-07-27 22:30:54 +00:00
|
|
|
The command cannot contain the character \257 (macron: ¯).
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{}>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
Input line. This replacement string will be replaced by a full line
|
2011-07-16 23:46:02 +00:00
|
|
|
read from the input source. The input source is normally stdin
|
|
|
|
(standard input), but can also be given with B<-a>, B<:::>, or
|
|
|
|
B<::::>.
|
2011-07-10 14:33:33 +00:00
|
|
|
|
|
|
|
The replacement string B<{}> can be changed with B<-I>.
|
|
|
|
|
|
|
|
If the command line contains no replacement strings then B<{}> will be
|
|
|
|
appended to the command line.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{.}>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
Input line without extension. This replacement string will be replaced
|
|
|
|
by the input with the extension removed. If the input line contains
|
|
|
|
B<.> after the last B</> the last B<.> till the end of the string will
|
|
|
|
be removed and B<{.}> will be replaced with the
|
|
|
|
remaining. E.g. I<foo.jpg> becomes I<foo>, I<subdir/foo.jpg> becomes
|
|
|
|
I<subdir/foo>, I<sub.dir/foo.jpg> becomes I<sub.dir/foo>,
|
|
|
|
I<sub.dir/bar> remains I<sub.dir/bar>. If the input line does not
|
|
|
|
contain B<.> it will remain unchanged.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-10-10 20:14:55 +00:00
|
|
|
The replacement string B<{.}> can be changed with B<--er>.
|
2011-07-10 14:33:33 +00:00
|
|
|
|
|
|
|
To understand replacement strings see B<{}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{/}>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
Basename of input line. This replacement string will be replaced by
|
|
|
|
the input with the directory part removed.
|
|
|
|
|
|
|
|
The replacement string B<{/}> can be changed with
|
|
|
|
B<--basenamereplace>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
To understand replacement strings see B<{}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{//}>
|
2011-04-27 15:12:35 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
Dirname of input line. This replacement string will be replaced by the
|
|
|
|
dir of the input line. See B<dirname>(1).
|
2011-04-27 15:12:35 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
The replacement string B<{//}> can be changed with
|
|
|
|
B<--dirnamereplace>.
|
|
|
|
|
|
|
|
To understand replacement strings see B<{}>.
|
2011-04-27 15:12:35 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{/.}>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
Basename of input line without extension. This replacement string will
|
|
|
|
be replaced by the input with the directory and extension part
|
|
|
|
removed. It is a combination of B<{/}> and B<{.}>.
|
|
|
|
|
|
|
|
The replacement string B<{/.}> can be changed with
|
|
|
|
B<--basenameextensionreplace>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
To understand replacement strings see B<{}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{#}>
|
2011-04-08 19:57:19 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
Sequence number of the job to run. This replacement string will be
|
|
|
|
replaced by the sequence number of the job being run. It contains the
|
|
|
|
same number as $PARALLEL_SEQ.
|
2011-04-08 19:57:19 +00:00
|
|
|
|
|
|
|
The replacement string B<{#}> can be changed with B<--seqreplace>.
|
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
To understand replacement strings see B<{}>.
|
|
|
|
|
2011-04-08 19:57:19 +00:00
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{%}>
|
2014-05-22 12:53:33 +00:00
|
|
|
|
|
|
|
Job slot number. This replacement string will be replaced by the job's
|
2014-05-31 06:42:56 +00:00
|
|
|
slot number between 1 and number of jobs to run in parallel. There
|
|
|
|
will never be 2 jobs running at the same time with the same job slot
|
|
|
|
number.
|
2014-05-22 12:53:33 +00:00
|
|
|
|
|
|
|
The replacement string B<{%}> can be changed with B<--slotreplace>.
|
|
|
|
|
|
|
|
To understand replacement strings see B<{}>.
|
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{>I<n>B<}>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
Argument from input source I<n> or the I<n>'th argument. This
|
|
|
|
positional replacement string will be replaced by the input from input
|
|
|
|
source I<n> (when used with B<-a> or B<::::>) or with the I<n>'th
|
2013-02-21 22:36:14 +00:00
|
|
|
argument (when used with B<-N>). If I<n> is negative it refers to the
|
|
|
|
I<n>'th last argument.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
To understand replacement strings see B<{}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{>I<n>.B<}>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-13 12:02:03 +00:00
|
|
|
Argument from input source I<n> or the I<n>'th argument without
|
2010-12-06 23:30:08 +00:00
|
|
|
extension. It is a combination of B<{>I<n>B<}> and B<{.}>.
|
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
This positional replacement string will be replaced by the input from
|
|
|
|
input source I<n> (when used with B<-a> or B<::::>) or with the
|
|
|
|
I<n>'th argument (when used with B<-N>). The input will have the
|
|
|
|
extension removed.
|
|
|
|
|
|
|
|
To understand positional replacement strings see B<{>I<n>B<}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{>I<n>/B<}>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-13 12:02:03 +00:00
|
|
|
Basename of argument from input source I<n> or the I<n>'th argument.
|
2011-07-10 14:33:33 +00:00
|
|
|
It is a combination of B<{>I<n>B<}> and B<{/}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
This positional replacement string will be replaced by the input from
|
|
|
|
input source I<n> (when used with B<-a> or B<::::>) or with the
|
|
|
|
I<n>'th argument (when used with B<-N>). The input will have the
|
|
|
|
directory (if any) removed.
|
|
|
|
|
|
|
|
To understand positional replacement strings see B<{>I<n>B<}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{>I<n>//B<}>
|
2012-03-15 20:23:53 +00:00
|
|
|
|
|
|
|
Dirname of argument from input source I<n> or the I<n>'th argument.
|
|
|
|
It is a combination of B<{>I<n>B<}> and B<{//}>.
|
|
|
|
|
|
|
|
This positional replacement string will be replaced by the dir of the
|
|
|
|
input from input source I<n> (when used with B<-a> or B<::::>) or with
|
|
|
|
the I<n>'th argument (when used with B<-N>). See B<dirname>(1).
|
|
|
|
|
|
|
|
To understand positional replacement strings see B<{>I<n>B<}>.
|
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{>I<n>/.B<}>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-13 12:02:03 +00:00
|
|
|
Basename of argument from input source I<n> or the I<n>'th argument
|
2010-12-06 23:30:08 +00:00
|
|
|
without extension. It is a combination of B<{>I<n>B<}>, B<{/}>, and
|
2011-07-10 14:33:33 +00:00
|
|
|
B<{.}>.
|
|
|
|
|
|
|
|
This positional replacement string will be replaced by the input from
|
|
|
|
input source I<n> (when used with B<-a> or B<::::>) or with the
|
|
|
|
I<n>'th argument (when used with B<-N>). The input will have the
|
|
|
|
directory (if any) and extension removed.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
To understand positional replacement strings see B<{>I<n>B<}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{=>I<perl expression>B<=}>
|
2014-07-14 16:25:45 +00:00
|
|
|
|
|
|
|
Replace with calculated I<perl expression>. B<$_> will contain the
|
|
|
|
same as B<{}>. After evaluating I<perl expression> B<$_> will be used
|
|
|
|
as the value. It is recommended to only change $_ but you have full
|
|
|
|
access to all of GNU B<parallel>'s internal functions and data
|
2016-09-04 08:42:04 +00:00
|
|
|
structures. A few convenience functions and data structures have been
|
|
|
|
made:
|
2014-07-14 16:25:45 +00:00
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
=over 15
|
|
|
|
|
|
|
|
=item Z<> B<Q(>I<string>B<)>
|
|
|
|
|
|
|
|
shell quote a string
|
|
|
|
|
2016-11-21 21:35:25 +00:00
|
|
|
=item Z<> B<pQ(>I<string>B<)>
|
|
|
|
|
|
|
|
perl quote a string
|
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
=item Z<> B<total_jobs()>
|
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
number of jobs in total
|
2015-12-22 17:42:33 +00:00
|
|
|
|
2017-02-05 01:46:29 +00:00
|
|
|
=item Z<> B<slot()>
|
2016-07-22 18:39:12 +00:00
|
|
|
|
|
|
|
slot number of job
|
|
|
|
|
2017-02-05 01:46:29 +00:00
|
|
|
=item Z<> B<seq()>
|
2016-07-22 18:39:12 +00:00
|
|
|
|
|
|
|
sequence number of job
|
|
|
|
|
2016-09-04 08:42:04 +00:00
|
|
|
=item Z<> B<@arg>
|
|
|
|
|
|
|
|
the arguments
|
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
=back
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
seq 10 | parallel echo {} + 1 is {= '$_++' =}
|
|
|
|
parallel csh -c {= '$_="mkdir ".Q($_)' =} ::: '12" dir'
|
|
|
|
seq 50 | parallel echo job {#} of {= '$_=total_jobs()' =}
|
2014-07-14 16:25:45 +00:00
|
|
|
|
|
|
|
See also: B<--rpl> B<--parens>
|
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<{=>I<n> I<perl expression>B<=}>
|
2014-07-14 16:25:45 +00:00
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
Positional equivalent to B<{=perl expression=}>. To understand
|
2014-07-14 16:25:45 +00:00
|
|
|
positional replacement strings see B<{>I<n>B<}>.
|
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
See also: B<{=perl expression=}> B<{>I<n>B<}>.
|
2014-07-14 16:25:45 +00:00
|
|
|
|
|
|
|
|
2016-05-22 20:43:53 +00:00
|
|
|
=item B<:::> I<arguments>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-16 23:46:02 +00:00
|
|
|
Use arguments from the command line as input source instead of stdin
|
|
|
|
(standard input). Unlike other options for GNU B<parallel> B<:::> is
|
|
|
|
placed after the I<command> and before the arguments.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
The following are equivalent:
|
|
|
|
|
|
|
|
(echo file1; echo file2) | parallel gzip
|
|
|
|
parallel gzip ::: file1 file2
|
|
|
|
parallel gzip {} ::: file1 file2
|
|
|
|
parallel --arg-sep ,, gzip {} ,, file1 file2
|
|
|
|
parallel --arg-sep ,, gzip ,, file1 file2
|
|
|
|
parallel ::: "gzip file1" "gzip file2"
|
|
|
|
|
|
|
|
To avoid treating B<:::> as special use B<--arg-sep> to set the
|
|
|
|
argument separator to something else. See also B<--arg-sep>.
|
|
|
|
|
2011-05-13 12:02:03 +00:00
|
|
|
If multiple B<:::> are given, each group will be treated as an input
|
|
|
|
source, and all combinations of input sources will be
|
|
|
|
generated. E.g. ::: 1 2 ::: a b c will result in the combinations
|
|
|
|
(1,a) (1,b) (1,c) (2,a) (2,b) (2,c). This is useful for replacing
|
|
|
|
nested for-loops.
|
2011-05-05 16:26:29 +00:00
|
|
|
|
|
|
|
B<:::> and B<::::> can be mixed. So these are equivalent:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-05 21:36:12 +00:00
|
|
|
parallel echo {1} {2} {3} ::: 6 7 ::: 4 5 ::: 1 2 3
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel echo {1} {2} {3} :::: <(seq 6 7) <(seq 4 5) \
|
|
|
|
:::: <(seq 1 3)
|
|
|
|
parallel -a <(seq 6 7) echo {1} {2} {3} :::: <(seq 4 5) \
|
|
|
|
:::: <(seq 1 3)
|
|
|
|
parallel -a <(seq 6 7) -a <(seq 4 5) echo {1} {2} {3} \
|
|
|
|
::: 1 2 3
|
|
|
|
seq 6 7 | parallel -a - -a <(seq 4 5) echo {1} {2} {3} \
|
|
|
|
::: 1 2 3
|
|
|
|
seq 4 5 | parallel echo {1} {2} {3} :::: <(seq 6 7) - \
|
|
|
|
::: 1 2 3
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-05 21:36:12 +00:00
|
|
|
|
2016-05-22 20:43:53 +00:00
|
|
|
=item B<:::+> I<arguments>
|
2016-03-26 09:35:13 +00:00
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
Like B<:::> but linked like B<--link> to the previous input source.
|
2016-03-26 09:35:13 +00:00
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
Contrary to B<--link>, values do not wrap: The shortest input source
|
2016-03-26 09:35:13 +00:00
|
|
|
determines the length.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
parallel echo ::: a b c :::+ 1 2 3 ::: X Y :::+ 11 22
|
|
|
|
|
|
|
|
|
2016-05-22 20:43:53 +00:00
|
|
|
=item B<::::> I<argfiles>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Another way to write B<-a> I<argfile1> B<-a> I<argfile2> ...
|
|
|
|
|
2011-05-13 12:02:03 +00:00
|
|
|
B<:::> and B<::::> can be mixed.
|
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
See B<-a>, B<:::> and B<--link>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2016-05-22 20:43:53 +00:00
|
|
|
=item B<::::+> I<argfiles>
|
2016-03-26 09:35:13 +00:00
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
Like B<::::> but linked like B<--link> to the previous input source.
|
2016-03-26 09:35:13 +00:00
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
Contrary to B<--link>, values do not wrap: The shortest input source
|
2016-03-26 09:35:13 +00:00
|
|
|
determines the length.
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--null>
|
|
|
|
|
|
|
|
=item B<-0>
|
|
|
|
|
|
|
|
Use NUL as delimiter. Normally input lines will end in \n
|
|
|
|
(newline). If they end in \0 (NUL), then use this option. It is useful
|
|
|
|
for processing arguments that may contain \n (newline).
|
|
|
|
|
|
|
|
|
2014-08-24 15:19:17 +00:00
|
|
|
=item B<--arg-file> I<input-file>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-08-24 15:19:17 +00:00
|
|
|
=item B<-a> I<input-file>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-26 21:19:58 +00:00
|
|
|
Use I<input-file> as input source. If you use this option, stdin
|
|
|
|
(standard input) is given to the first process run. Otherwise, stdin
|
|
|
|
(standard input) is redirected from /dev/null.
|
2011-05-04 18:55:01 +00:00
|
|
|
|
2011-05-13 12:02:03 +00:00
|
|
|
If multiple B<-a> are given, each I<input-file> will be treated as an
|
|
|
|
input source, and all combinations of input sources will be
|
|
|
|
generated. E.g. The file B<foo> contains B<1 2>, the file B<bar>
|
|
|
|
contains B<a b c>. B<-a foo> B<-a bar> will result in the combinations
|
|
|
|
(1,a) (1,b) (1,c) (2,a) (2,b) (2,c). This is useful for replacing
|
|
|
|
nested for-loops.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
See also B<--link> and B<{>I<n>B<}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-13 12:02:03 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--arg-file-sep> I<sep-str>
|
|
|
|
|
|
|
|
Use I<sep-str> instead of B<::::> as separator string between command
|
|
|
|
and argument files. Useful if B<::::> is used for something else by the
|
|
|
|
command.
|
|
|
|
|
|
|
|
See also: B<::::>.
|
|
|
|
|
|
|
|
|
|
|
|
=item B<--arg-sep> I<sep-str>
|
|
|
|
|
|
|
|
Use I<sep-str> instead of B<:::> as separator string. Useful if B<:::>
|
|
|
|
is used for something else by the command.
|
|
|
|
|
|
|
|
Also useful if you command uses B<:::> but you still want to read
|
|
|
|
arguments from stdin (standard input): Simply change B<--arg-sep> to a
|
|
|
|
string that is not in the command line.
|
|
|
|
|
|
|
|
See also: B<:::>.
|
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--bar>
|
2013-11-22 22:31:46 +00:00
|
|
|
|
|
|
|
Show progress as a progress bar. In the bar is shown: % of jobs
|
|
|
|
completed, estimated seconds left, and number of jobs started.
|
|
|
|
|
|
|
|
It is compatible with B<zenity>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq 1000 | parallel -j30 --bar '(echo {};sleep 0.1)' \
|
|
|
|
2> >(zenity --progress --auto-kill) | wc
|
2013-11-22 22:31:46 +00:00
|
|
|
|
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--basefile> I<file>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--bf> I<file>
|
2011-10-10 20:14:55 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
I<file> will be transferred to each sshlogin before a jobs is
|
|
|
|
started. It will be removed if B<--cleanup> is active. The file may be
|
|
|
|
a script to run or some common base data needed for the jobs.
|
2012-01-07 01:24:50 +00:00
|
|
|
Multiple B<--bf> can be specified to transfer more basefiles. The
|
2015-12-13 11:20:50 +00:00
|
|
|
I<file> will be transferred the same way as B<--transferfile>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2011-01-24 19:06:30 +00:00
|
|
|
=item B<--basenamereplace> I<replace-str>
|
|
|
|
|
|
|
|
=item B<--bnr> I<replace-str>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-04-08 19:57:19 +00:00
|
|
|
Use the replacement string I<replace-str> instead of B<{/}> for
|
|
|
|
basename of input line.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2011-03-01 22:04:15 +00:00
|
|
|
=item B<--basenameextensionreplace> I<replace-str>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-07-16 23:46:02 +00:00
|
|
|
=item B<--bner> I<replace-str>
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
Use the replacement string I<replace-str> instead of B<{/.}> for basename of input line without extension.
|
|
|
|
|
|
|
|
|
2011-05-05 18:50:53 +00:00
|
|
|
=item B<--bg>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Run command in background thus GNU B<parallel> will not wait for
|
|
|
|
completion of the command before exiting. This is the default if
|
|
|
|
B<--semaphore> is set.
|
|
|
|
|
2013-08-14 18:11:00 +00:00
|
|
|
See also: B<--fg>, B<man sem>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Implies B<--semaphore>.
|
|
|
|
|
|
|
|
|
2014-01-22 02:06:39 +00:00
|
|
|
=item B<--bibtex>
|
2011-10-22 23:49:32 +00:00
|
|
|
|
2015-08-10 22:25:37 +00:00
|
|
|
=item B<--citation>
|
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
Print the BibTeX entry for GNU B<parallel> and silence citation
|
2013-11-22 22:31:46 +00:00
|
|
|
notice.
|
2011-10-22 23:49:32 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
If it is impossible for you to run B<--bibtex> you can use
|
|
|
|
B<--will-cite>.
|
|
|
|
|
|
|
|
If you use B<--will-cite> in scripts to be run by others you are
|
|
|
|
making it harder for others to see the citation notice. The
|
|
|
|
development of GNU B<parallel> is indirectly financed through
|
2016-04-11 20:19:28 +00:00
|
|
|
citations, so if your users do not know they should cite then you are
|
2016-04-09 21:57:50 +00:00
|
|
|
making it harder to finance development. However, if you pay 10000
|
2016-04-11 20:19:28 +00:00
|
|
|
EUR, you should feel free to use B<--will-cite> in scripts.
|
2015-05-10 13:02:07 +00:00
|
|
|
|
2011-10-22 23:49:32 +00:00
|
|
|
|
2017-01-21 18:55:14 +00:00
|
|
|
=item B<--block> I<size>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2017-01-21 18:55:14 +00:00
|
|
|
=item B<--block-size> I<size>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2015-06-26 22:29:28 +00:00
|
|
|
Size of block in bytes to read at a time. The I<size> can be postfixed
|
2017-01-01 11:42:52 +00:00
|
|
|
with K, M, G, T, P, E, k, m, g, t, p, or e which would multiply the
|
|
|
|
size with 1024, 1048576, 1073741824, 1099511627776, 1125899906842624,
|
|
|
|
1152921504606846976, 1000, 1000000, 1000000000, 1000000000000,
|
|
|
|
1000000000000000, or 1000000000000000000 respectively.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
|
|
|
GNU B<parallel> tries to meet the block size but can be off by the
|
2012-09-23 21:21:13 +00:00
|
|
|
length of one record. For performance reasons I<size> should be bigger
|
2015-06-26 22:29:28 +00:00
|
|
|
than a two records. GNU B<parallel> will warn you and automatically
|
|
|
|
increase the size if you choose a I<size> that is too small.
|
|
|
|
|
|
|
|
If you use B<-N>, B<--block-size> should be bigger than N+1 records.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
|
|
|
I<size> defaults to 1M.
|
|
|
|
|
2016-12-22 13:27:00 +00:00
|
|
|
When using B<--pipepart> a negative block size is not interpreted as a
|
2016-12-08 01:28:01 +00:00
|
|
|
blocksize but as the number of blocks each jobslot should have. So
|
|
|
|
this will run 10*5 = 50 jobs in total:
|
|
|
|
|
|
|
|
parallel --pipepart -a myfile --block -10 -j5 wc
|
|
|
|
|
2016-12-08 11:04:22 +00:00
|
|
|
This is an efficient alternative to B<--round-robin> because data is
|
|
|
|
never read by GNU B<parallel>, but you can still have very few
|
|
|
|
jobslots process a large amount of data.
|
2016-12-08 01:28:01 +00:00
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
See B<--pipe> and B<--pipepart> for use of this.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--cat>
|
2014-03-23 00:07:18 +00:00
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
Create a temporary file with content. Normally B<--pipe>/B<--pipepart>
|
|
|
|
will give data to the program on stdin (standard input). With B<--cat>
|
2016-06-22 19:43:05 +00:00
|
|
|
GNU B<parallel> will create a temporary file with the name in B<{}>, so
|
2014-11-15 14:25:19 +00:00
|
|
|
you can do: B<parallel --pipe --cat wc {}>.
|
2014-03-23 00:07:18 +00:00
|
|
|
|
2015-05-15 15:25:19 +00:00
|
|
|
Implies B<--pipe> unless B<--pipepart> is used.
|
|
|
|
|
2014-03-23 00:07:18 +00:00
|
|
|
See also B<--fifo>.
|
|
|
|
|
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--cleanup>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
Remove transferred files. B<--cleanup> will remove the transferred
|
|
|
|
files on the remote computer after processing is done.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
find log -name '*gz' | parallel \
|
2015-12-13 11:20:50 +00:00
|
|
|
--sshlogin server.example.com --transferfile {} \
|
2014-11-11 14:51:19 +00:00
|
|
|
--return {.}.bz2 --cleanup "zcat {} | bzip -9 >{.}.bz2"
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
With B<--transferfile {}> the file transferred to the remote computer
|
|
|
|
will be removed on the remote computer. Directories created will not
|
|
|
|
be removed - even if they are empty.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
With B<--return> the file transferred from the remote computer will be
|
2015-12-13 11:20:50 +00:00
|
|
|
removed on the remote computer. Directories created will not be
|
|
|
|
removed - even if they are empty.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
B<--cleanup> is ignored when not used with B<--transferfile> or
|
|
|
|
B<--return>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--colsep> I<regexp>
|
|
|
|
|
|
|
|
=item B<-C> I<regexp>
|
|
|
|
|
|
|
|
Column separator. The input will be treated as a table with I<regexp>
|
|
|
|
separating the columns. The n'th column can be access using
|
|
|
|
B<{>I<n>B<}> or B<{>I<n>.B<}>. E.g. B<{3}> is the 3rd column.
|
|
|
|
|
|
|
|
B<--colsep> implies B<--trim rl>.
|
|
|
|
|
|
|
|
I<regexp> is a Perl Regular Expression:
|
|
|
|
http://perldoc.perl.org/perlre.html
|
|
|
|
|
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--compress>
|
2013-11-02 22:17:20 +00:00
|
|
|
|
|
|
|
Compress temporary files. If the output is big and very compressible
|
2014-09-07 15:10:44 +00:00
|
|
|
this will take up less disk space in $TMPDIR and possibly be faster
|
|
|
|
due to less disk I/O.
|
2013-11-02 22:17:20 +00:00
|
|
|
|
2016-12-18 10:14:06 +00:00
|
|
|
GNU B<parallel> will try B<pzstd>, B<lbzip2>, B<pbzip2>, B<zstd>,
|
|
|
|
B<pigz>, B<lz4>, B<lzop>, B<plzip>, B<lzip>, B<lrz>, B<gzip>, B<pxz>,
|
|
|
|
B<lzma>, B<bzip2>, B<xz>, B<clzip>, in that order, and use the first
|
|
|
|
available.
|
2013-11-02 22:17:20 +00:00
|
|
|
|
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--compress-program> I<prg>
|
2013-11-02 22:17:20 +00:00
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--decompress-program> I<prg>
|
2014-02-22 10:32:42 +00:00
|
|
|
|
|
|
|
Use I<prg> for (de)compressing temporary files. It is assumed that I<prg
|
2013-11-02 22:17:20 +00:00
|
|
|
-dc> will decompress stdin (standard input) to stdout (standard
|
2014-02-22 10:32:42 +00:00
|
|
|
output) unless B<--decompress-program> is given.
|
2013-11-02 22:17:20 +00:00
|
|
|
|
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--delimiter> I<delim>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<-d> I<delim>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
Input items are terminated by I<delim>. Quotes and backslash are not
|
|
|
|
special; every character in the input is taken literally. Disables
|
|
|
|
the end-of-file string, which is treated like any other argument. The
|
|
|
|
specified delimiter may be characters, C-style character escapes such
|
|
|
|
as \n, or octal or hexadecimal escape codes. Octal and hexadecimal
|
|
|
|
escape codes are understood as for the printf command. Multibyte
|
|
|
|
characters are not supported.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-08-21 23:01:57 +00:00
|
|
|
=item B<--dirnamereplace> I<replace-str>
|
2011-04-27 15:12:35 +00:00
|
|
|
|
2011-08-21 23:01:57 +00:00
|
|
|
=item B<--dnr> I<replace-str>
|
2011-04-27 15:12:35 +00:00
|
|
|
|
|
|
|
Use the replacement string I<replace-str> instead of B<{//}> for
|
|
|
|
dirname of input line.
|
|
|
|
|
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<-E> I<eof-str>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
Set the end of file string to I<eof-str>. If the end of file string
|
|
|
|
occurs as a line of input, the rest of the input is not read. If
|
2010-12-06 23:30:08 +00:00
|
|
|
neither B<-E> nor B<-e> is used, no end of file string is used.
|
|
|
|
|
|
|
|
|
2013-10-21 20:31:52 +00:00
|
|
|
=item B<--delay> I<secs>
|
2012-11-26 21:57:07 +00:00
|
|
|
|
|
|
|
Delay starting next job I<secs> seconds. GNU B<parallel> will pause
|
|
|
|
I<secs> seconds after starting each job. I<secs> can be less than 1
|
2014-11-15 14:25:19 +00:00
|
|
|
second.
|
2012-11-26 21:57:07 +00:00
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--dry-run>
|
2010-12-15 23:12:02 +00:00
|
|
|
|
2011-05-26 21:19:58 +00:00
|
|
|
Print the job to run on stdout (standard output), but do not run the
|
2014-11-15 14:25:19 +00:00
|
|
|
job. Use B<-v -v> to include the wrapping that GNU Parallel generates
|
|
|
|
(for remote jobs, B<--tmux>, B<--nice>, B<--pipe>, B<--pipepart>,
|
|
|
|
B<--fifo> and B<--cat>). Do not count on this literaly, though, as the
|
|
|
|
job may be scheduled on another computer or the local computer if : is
|
|
|
|
in the list.
|
2010-12-15 23:12:02 +00:00
|
|
|
|
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<--eof>[=I<eof-str>]
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<-e>[I<eof-str>]
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
This option is a synonym for the B<-E> option. Use B<-E> instead,
|
|
|
|
because it is POSIX compliant for B<xargs> while this option is not.
|
|
|
|
If I<eof-str> is omitted, there is no end of file string. If neither
|
|
|
|
B<-E> nor B<-e> is used, no end of file string is used.
|
|
|
|
|
|
|
|
|
2017-03-02 21:40:46 +00:00
|
|
|
=item B<--env> I<var>
|
2012-10-15 13:47:10 +00:00
|
|
|
|
|
|
|
Copy environment variable I<var>. This will copy I<var> to the
|
|
|
|
environment that the command is run in. This is especially useful for
|
2013-07-20 15:33:26 +00:00
|
|
|
remote execution.
|
2012-10-15 13:47:10 +00:00
|
|
|
|
2013-07-20 15:33:26 +00:00
|
|
|
In Bash I<var> can also be a Bash function - just remember to B<export
|
2014-03-31 19:29:47 +00:00
|
|
|
-f> the function, see B<command>.
|
2012-10-15 13:47:10 +00:00
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
The variable '_' is special. It will copy all exported environment
|
|
|
|
variables except for the ones mentioned in ~/.parallel/ignored_vars.
|
2013-08-14 18:11:00 +00:00
|
|
|
|
2016-04-21 22:36:46 +00:00
|
|
|
To copy the full environment (both exported and not exported
|
2016-08-03 21:42:15 +00:00
|
|
|
variables, arrays, and functions) use B<env_parallel>.
|
2014-08-22 22:39:59 +00:00
|
|
|
|
2013-08-14 18:11:00 +00:00
|
|
|
See also: B<--record-env>.
|
|
|
|
|
2012-10-15 13:47:10 +00:00
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--eta>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Show the estimated number of seconds before finishing. This forces GNU
|
|
|
|
B<parallel> to read all jobs before starting to find the number of
|
|
|
|
jobs. GNU B<parallel> normally only reads the next job to run.
|
2014-11-15 14:25:19 +00:00
|
|
|
|
2016-06-27 19:00:19 +00:00
|
|
|
The estimate is based on the runtime of finished jobs, so the first
|
|
|
|
estimate will only be shown when the first job has finished.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
Implies B<--progress>.
|
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
See also: B<--bar>, B<--progress>.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-05 18:50:53 +00:00
|
|
|
=item B<--fg>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2017-02-04 15:01:42 +00:00
|
|
|
Run command in foreground.
|
|
|
|
|
|
|
|
With B<--tmux> and B<--tmuxpane> GNU B<parallel> will start B<tmux> in
|
|
|
|
the foreground.
|
|
|
|
|
|
|
|
With B<--semaphore> GNU B<parallel> will run the command in the
|
|
|
|
foreground (opposite B<--bg>), and wait for completion of the command
|
|
|
|
before exiting.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
See also B<--bg>, B<man sem>.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--fifo>
|
2014-03-23 00:07:18 +00:00
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
Create a temporary fifo with content. Normally B<--pipe> and
|
|
|
|
B<--pipepart> will give data to the program on stdin (standard
|
|
|
|
input). With B<--fifo> GNU B<parallel> will create a temporary fifo
|
2016-06-22 19:43:05 +00:00
|
|
|
with the name in B<{}>, so you can do: B<parallel --pipe --fifo wc {}>.
|
2014-03-23 00:07:18 +00:00
|
|
|
|
|
|
|
Beware: If data is not read from the fifo, the job will block forever.
|
|
|
|
|
2015-05-15 15:25:19 +00:00
|
|
|
Implies B<--pipe> unless B<--pipepart> is used.
|
|
|
|
|
2014-03-23 00:07:18 +00:00
|
|
|
See also B<--cat>.
|
|
|
|
|
|
|
|
|
2014-02-22 10:32:42 +00:00
|
|
|
=item B<--filter-hosts>
|
2012-06-23 05:34:35 +00:00
|
|
|
|
|
|
|
Remove down hosts. For each remote host: check that login through ssh
|
|
|
|
works. If not: do not use this host.
|
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
For performance reasons, this check is performed only at the start and
|
|
|
|
every time B<--sshloginfile> is changed. If an host goes down after
|
|
|
|
the first check, it will go undetected until B<--sshloginfile> is
|
|
|
|
changed; B<--retries> can be used to mitigate this.
|
|
|
|
|
2013-02-10 12:32:50 +00:00
|
|
|
Currently you can I<not> put B<--filter-hosts> in a profile,
|
2012-06-23 05:34:35 +00:00
|
|
|
$PARALLEL, /etc/parallel/config or similar. This is because GNU
|
|
|
|
B<parallel> uses GNU B<parallel> to compute this, so you will get an
|
|
|
|
infinite loop. This will likely be fixed in a later release.
|
|
|
|
|
|
|
|
|
2014-07-27 22:30:54 +00:00
|
|
|
=item B<--gnu>
|
2011-02-18 14:23:00 +00:00
|
|
|
|
2014-09-18 20:09:20 +00:00
|
|
|
Behave like GNU B<parallel>. This option historically took precedence
|
|
|
|
over B<--tollef>. The B<--tollef> option is now retired, and therefore
|
|
|
|
may not be used. B<--gnu> is kept for compatibility.
|
2011-02-18 14:23:00 +00:00
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--group>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-08-09 20:00:31 +00:00
|
|
|
Group output. Output from each jobs is grouped together and is only
|
2017-03-11 20:19:10 +00:00
|
|
|
printed when the command is finished. stdout (standard output) first
|
|
|
|
followed by stderr (standard error). This takes some CPU time. In rare
|
|
|
|
situations GNU B<parallel> takes up lots of CPU time and if it is
|
2011-12-09 22:25:20 +00:00
|
|
|
acceptable that the outputs from different commands are mixed
|
|
|
|
together, then disabling grouping with B<-u> can speedup GNU
|
|
|
|
B<parallel> by a factor of 10.
|
2011-08-09 20:00:31 +00:00
|
|
|
|
2011-10-10 20:14:55 +00:00
|
|
|
B<--group> is the default. Can be reversed with B<-u>.
|
2011-08-09 20:00:31 +00:00
|
|
|
|
2014-05-22 12:53:33 +00:00
|
|
|
See also: B<--line-buffer> B<--ungroup>
|
|
|
|
|
2011-02-18 14:23:00 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--help>
|
|
|
|
|
|
|
|
=item B<-h>
|
|
|
|
|
|
|
|
Print a summary of the options to GNU B<parallel> and exit.
|
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--halt-on-error> I<val>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--halt> I<val>
|
2011-10-10 20:14:55 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
When should GNU B<parallel> terminate? In some situations it makes no
|
|
|
|
sense to run all jobs. GNU B<parallel> should simply give up as soon
|
|
|
|
as a condition is met.
|
|
|
|
|
|
|
|
I<val> defaults to B<never>, which runs all jobs no matter what.
|
|
|
|
|
|
|
|
I<val> can also take on the form of I<when>,I<why>.
|
|
|
|
|
|
|
|
I<when> can be 'now' which means kill all running jobs and halt
|
|
|
|
immediately, or it can be 'soon' which means wait for all running jobs
|
|
|
|
to complete, but start no new jobs.
|
|
|
|
|
|
|
|
I<why> can be 'fail=X', 'fail=Y%', 'success=X', or 'success=Y%' where
|
|
|
|
X is the number of jobs that has to fail or succeed before halting,
|
|
|
|
and Y is the percentage of jobs that has to fail or succeed before
|
|
|
|
halting.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
=over 23
|
|
|
|
|
|
|
|
=item Z<> --halt now,fail=1
|
|
|
|
|
|
|
|
exit when the first job fails. Kill running jobs.
|
|
|
|
|
|
|
|
=item Z<> --halt soon,fail=3
|
|
|
|
|
|
|
|
exit when 3 jobs fail, but wait for running jobs to complete.
|
|
|
|
|
|
|
|
=item Z<> --halt soon,fail=3%
|
|
|
|
|
|
|
|
exit when 3% of the jobs have failed, but wait for running jobs to complete.
|
|
|
|
|
|
|
|
=item Z<> --halt now,success=1
|
|
|
|
|
|
|
|
exit when a job succeeds. Kill running jobs.
|
|
|
|
|
|
|
|
=item Z<> --halt soon,success=3
|
|
|
|
|
|
|
|
exit when 3 jobs succeeds, but wait for running jobs to complete.
|
|
|
|
|
|
|
|
=item Z<> --halt now,success=3%
|
|
|
|
|
|
|
|
exit when 3% of the jobs have succeeded. Kill running jobs.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
For backwards compability these also work:
|
2014-07-20 17:55:53 +00:00
|
|
|
|
|
|
|
=over 7
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-07-26 12:58:42 +00:00
|
|
|
=item Z<>0
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
never
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-07-26 12:58:42 +00:00
|
|
|
=item Z<>1
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
soon,fail=1
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-07-26 12:58:42 +00:00
|
|
|
=item Z<>2
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
now,fail=1
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-01-02 11:55:02 +00:00
|
|
|
=item Z<>-1
|
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
soon,success=1
|
2015-01-02 11:55:02 +00:00
|
|
|
|
|
|
|
=item Z<>-2
|
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
now,success=1
|
2015-01-02 11:55:02 +00:00
|
|
|
|
2014-07-20 17:55:53 +00:00
|
|
|
=item Z<>1-99%
|
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
soon,fail=1-99%
|
2014-07-20 17:55:53 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=back
|
|
|
|
|
|
|
|
|
2013-10-21 20:31:52 +00:00
|
|
|
=item B<--header> I<regexp>
|
2012-01-13 23:53:19 +00:00
|
|
|
|
2013-08-17 16:24:51 +00:00
|
|
|
Use regexp as header. For normal usage the matched header (typically
|
|
|
|
the first line: B<--header '.*\n'>) will be split using B<--colsep>
|
|
|
|
(which will default to '\t') and column names can be used as
|
2016-11-06 11:29:48 +00:00
|
|
|
replacement variables: B<{column name}>, B<{column name/}>, B<{column
|
|
|
|
name//}>, B<{column name/.}>, B<{column name.}>, B<{=column name perl
|
|
|
|
expression =}>, ..
|
2012-01-13 23:53:19 +00:00
|
|
|
|
2013-08-17 16:24:51 +00:00
|
|
|
For B<--pipe> the matched header will be prepended to each output.
|
|
|
|
|
|
|
|
B<--header :> is an alias for B<--header '.*\n'>.
|
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
If I<regexp> is a number, it is a fixed number of lines.
|
2012-01-13 23:53:19 +00:00
|
|
|
|
|
|
|
|
2015-02-01 13:38:26 +00:00
|
|
|
=item B<--hostgroups>
|
2014-11-11 14:51:19 +00:00
|
|
|
|
2015-02-01 13:38:26 +00:00
|
|
|
=item B<--hgrp>
|
2014-11-11 14:51:19 +00:00
|
|
|
|
|
|
|
Enable hostgroups on arguments. If an argument contains '@' the string
|
|
|
|
after '@' will be removed and treated as a list of hostgroups on which
|
|
|
|
this job is allowed to run. If there is no B<--sshlogin> with a
|
|
|
|
corresponding group, the job will run on any hostgroup.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
parallel --hostgroups \
|
|
|
|
--sshlogin @grp1/myserver1 -S @grp1+grp2/myserver2 \
|
2014-11-13 03:19:33 +00:00
|
|
|
--sshlogin @grp3/myserver3 \
|
2017-03-21 21:20:38 +00:00
|
|
|
echo ::: my_grp1_arg@grp1 arg_for_grp2@grp2 third@grp1+grp3
|
2014-11-11 14:51:19 +00:00
|
|
|
|
2014-11-13 03:19:33 +00:00
|
|
|
B<my_grp1_arg> may be run on either B<myserver1> or B<myserver2>,
|
2017-03-21 21:20:38 +00:00
|
|
|
B<third> may be run on either B<myserver1> or B<myserver3>,
|
2014-11-13 03:19:33 +00:00
|
|
|
but B<arg_for_grp2> will only be run on B<myserver2>.
|
2014-11-11 14:51:19 +00:00
|
|
|
|
2015-04-17 21:51:45 +00:00
|
|
|
See also: B<--sshlogin>.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<-I> I<replace-str>
|
|
|
|
|
2016-06-22 19:43:05 +00:00
|
|
|
Use the replacement string I<replace-str> instead of B<{}>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<--replace>[=I<replace-str>]
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<-i>[I<replace-str>]
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
This option is a synonym for B<-I>I<replace-str> if I<replace-str> is
|
2016-06-22 19:43:05 +00:00
|
|
|
specified, and for B<-I {}> otherwise. This option is deprecated;
|
2010-12-06 23:30:08 +00:00
|
|
|
use B<-I> instead.
|
|
|
|
|
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--joblog> I<logfile>
|
2011-01-18 17:15:42 +00:00
|
|
|
|
2012-03-12 22:38:38 +00:00
|
|
|
Logfile for executed jobs. Save a list of the executed jobs to
|
2011-01-19 15:25:25 +00:00
|
|
|
I<logfile> in the following TAB separated format: sequence number,
|
|
|
|
sshlogin, start time as seconds since epoch, run time in seconds,
|
2012-05-27 16:14:25 +00:00
|
|
|
bytes in files transferred, bytes in files returned, exit status,
|
2013-11-28 14:24:34 +00:00
|
|
|
signal, and command run.
|
2011-01-18 17:15:42 +00:00
|
|
|
|
2015-03-22 01:27:01 +00:00
|
|
|
For B<--pipe> bytes transferred and bytes returned are number of input
|
|
|
|
and output of bytes.
|
|
|
|
|
2011-01-18 17:15:42 +00:00
|
|
|
To convert the times into ISO-8601 strict do:
|
2011-01-19 15:25:25 +00:00
|
|
|
|
2017-02-04 15:01:42 +00:00
|
|
|
cat joblog | perl -a -F"\t" -ne \
|
2014-11-11 14:51:19 +00:00
|
|
|
'chomp($F[2]=`date -d \@$F[2] +%FT%T`); print join("\t",@F)'
|
2011-01-18 17:15:42 +00:00
|
|
|
|
2017-02-04 15:01:42 +00:00
|
|
|
If the host is long, you can use B<column -t> to pretty print it:
|
|
|
|
|
|
|
|
cat joblog | column -t
|
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
See also B<--resume> B<--resume-failed>.
|
2012-01-07 02:29:48 +00:00
|
|
|
|
2011-01-18 17:15:42 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--jobs> I<N>
|
|
|
|
|
|
|
|
=item B<-j> I<N>
|
|
|
|
|
|
|
|
=item B<--max-procs> I<N>
|
|
|
|
|
|
|
|
=item B<-P> I<N>
|
|
|
|
|
2015-05-06 22:40:36 +00:00
|
|
|
Number of jobslots on each machine. Run up to N jobs in parallel. 0
|
|
|
|
means as many as possible. Default is 100% which will run one job per
|
|
|
|
CPU core on each machine.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 19:38:57 +00:00
|
|
|
If B<--semaphore> is set, the default is 1 thus making a mutex.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--jobs> I<+N>
|
|
|
|
|
|
|
|
=item B<-j> I<+N>
|
|
|
|
|
|
|
|
=item B<--max-procs> I<+N>
|
|
|
|
|
|
|
|
=item B<-P> I<+N>
|
|
|
|
|
2012-03-15 20:23:53 +00:00
|
|
|
Add N to the number of CPU cores. Run this many jobs in parallel.
|
|
|
|
See also B<--use-cpus-instead-of-cores>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--jobs> I<-N>
|
|
|
|
|
|
|
|
=item B<-j> I<-N>
|
|
|
|
|
|
|
|
=item B<--max-procs> I<-N>
|
|
|
|
|
|
|
|
=item B<-P> I<-N>
|
|
|
|
|
|
|
|
Subtract N from the number of CPU cores. Run this many jobs in parallel.
|
|
|
|
If the evaluated number is less than 1 then 1 will be used. See also
|
|
|
|
B<--use-cpus-instead-of-cores>.
|
|
|
|
|
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<--jobs> I<N>%
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<-j> I<N>%
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<--max-procs> I<N>%
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<-P> I<N>%
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-08-22 22:39:59 +00:00
|
|
|
Multiply N% with the number of CPU cores. Run this many jobs in
|
|
|
|
parallel. See also B<--use-cpus-instead-of-cores>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--jobs> I<procfile>
|
|
|
|
|
|
|
|
=item B<-j> I<procfile>
|
|
|
|
|
|
|
|
=item B<--max-procs> I<procfile>
|
|
|
|
|
|
|
|
=item B<-P> I<procfile>
|
|
|
|
|
|
|
|
Read parameter from file. Use the content of I<procfile> as parameter
|
|
|
|
for I<-j>. E.g. I<procfile> could contain the string 100% or +2 or
|
|
|
|
10. If I<procfile> is changed when a job completes, I<procfile> is
|
|
|
|
read again and the new number of jobs is computed. If the number is
|
|
|
|
lower than before, running jobs will be allowed to finish but new jobs
|
|
|
|
will not be started until the wanted number of jobs has been reached.
|
|
|
|
This makes it possible to change the number of simultaneous running
|
|
|
|
jobs while GNU B<parallel> is running.
|
|
|
|
|
|
|
|
|
2011-05-05 16:26:29 +00:00
|
|
|
=item B<--keep-order>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=item B<-k>
|
|
|
|
|
2011-10-17 01:10:32 +00:00
|
|
|
Keep sequence of output same as the order of input. Normally the
|
|
|
|
output of a job will be printed as soon as the job completes. Try this
|
|
|
|
to see the difference:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-05 16:26:29 +00:00
|
|
|
parallel -j4 sleep {}\; echo {} ::: 2 1 4 3
|
|
|
|
parallel -j4 -k sleep {}\; echo {} ::: 2 1 4 3
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-01-22 01:54:18 +00:00
|
|
|
If used with B<--onall> or B<--nonall> the output will grouped by
|
|
|
|
sshlogin in sorted order.
|
2013-11-29 00:56:35 +00:00
|
|
|
|
2017-02-04 23:27:10 +00:00
|
|
|
If used with B<--pipe --roundrobin> and the same input, the jobslots
|
|
|
|
will get the same blocks in the same order in every run.
|
|
|
|
|
2013-11-29 00:56:35 +00:00
|
|
|
|
2012-08-08 19:25:18 +00:00
|
|
|
=item B<-L> I<max-lines>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-05-21 22:29:41 +00:00
|
|
|
When used with B<--pipe>: Read records of I<max-lines>.
|
2012-06-14 21:13:11 +00:00
|
|
|
|
|
|
|
When used otherwise: Use at most I<max-lines> nonblank input lines per
|
|
|
|
command line. Trailing blanks cause an input line to be logically
|
|
|
|
continued on the next input line.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-02-23 15:22:08 +00:00
|
|
|
B<-L 0> means read one line, but insert 0 arguments on the command
|
|
|
|
line.
|
|
|
|
|
2012-06-14 21:13:11 +00:00
|
|
|
Implies B<-X> unless B<-m>, B<--xargs>, or B<--pipe> is set.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--max-lines>[=I<max-lines>]
|
|
|
|
|
|
|
|
=item B<-l>[I<max-lines>]
|
|
|
|
|
2013-05-21 22:29:41 +00:00
|
|
|
When used with B<--pipe>: Read records of I<max-lines>.
|
2012-06-14 21:13:11 +00:00
|
|
|
|
|
|
|
When used otherwise: Synonym for the B<-L> option. Unlike B<-L>, the
|
|
|
|
I<max-lines> argument is optional. If I<max-lines> is not specified,
|
|
|
|
it defaults to one. The B<-l> option is deprecated since the POSIX
|
|
|
|
standard specifies B<-L> instead.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-03-01 22:04:15 +00:00
|
|
|
B<-l 0> is an alias for B<-l 1>.
|
2011-02-23 15:22:08 +00:00
|
|
|
|
2012-06-14 22:46:15 +00:00
|
|
|
Implies B<-X> unless B<-m>, B<--xargs>, or B<--pipe> is set.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2014-07-14 16:25:45 +00:00
|
|
|
=item B<--line-buffer>
|
2013-08-22 15:24:36 +00:00
|
|
|
|
2015-05-20 19:09:33 +00:00
|
|
|
=item B<--lb>
|
|
|
|
|
2013-08-22 15:24:36 +00:00
|
|
|
Buffer output on line basis. B<--group> will keep the output together
|
|
|
|
for a whole job. B<--ungroup> allows output to mixup with half a line
|
|
|
|
coming from one job and half a line coming from another
|
|
|
|
job. B<--line-buffer> fits between these two: GNU B<parallel> will
|
|
|
|
print a full line, but will allow for mixing lines of different jobs.
|
|
|
|
|
2014-05-22 12:53:33 +00:00
|
|
|
B<--line-buffer> takes more CPU power than than both B<--group> and
|
|
|
|
B<--ungroup>, but can be faster than B<--group> if the CPU is not the
|
|
|
|
limiting factor.
|
|
|
|
|
|
|
|
See also: B<--group> B<--ungroup>
|
2013-08-22 15:24:36 +00:00
|
|
|
|
|
|
|
|
2016-10-22 11:39:31 +00:00
|
|
|
=item B<--xapply>
|
2016-08-13 17:11:15 +00:00
|
|
|
|
2016-10-22 11:39:31 +00:00
|
|
|
=item B<--link>
|
2016-08-13 17:11:15 +00:00
|
|
|
|
|
|
|
Link input sources. Read multiple input sources like B<xapply>. If
|
|
|
|
multiple input sources are given, one argument will be read from each
|
|
|
|
of the input sources. The arguments can be accessed in the command as
|
|
|
|
B<{1}> .. B<{>I<n>B<}>, so B<{1}> will be a line from the first input
|
|
|
|
source, and B<{6}> will refer to the line with the same line number
|
|
|
|
from the 6th input source.
|
|
|
|
|
|
|
|
Compare these two:
|
|
|
|
|
|
|
|
parallel echo {1} {2} ::: 1 2 3 ::: a b c
|
|
|
|
parallel --link echo {1} {2} ::: 1 2 3 ::: a b c
|
|
|
|
|
|
|
|
Arguments will be recycled if one input source has more arguments than the others:
|
|
|
|
|
|
|
|
parallel --link echo {1} {2} {3} \
|
|
|
|
::: 1 2 ::: I II III ::: a b c d e f g
|
|
|
|
|
|
|
|
See also B<--header>, B<:::+>, B<::::+>.
|
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<--load> I<max-load>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-04-21 21:33:02 +00:00
|
|
|
Do not start new jobs on a given computer unless the number of running
|
|
|
|
processes on the computer is less than I<max-load>. I<max-load> uses
|
|
|
|
the same syntax as B<--jobs>, so I<100%> for one per CPU is a valid
|
|
|
|
setting. Only difference is 0 which is interpreted as 0.01.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--controlmaster>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<-M>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Use ssh's ControlMaster to make ssh connections faster. Useful if jobs
|
|
|
|
run remote and are very fast to run. This is disabled for sshlogins
|
|
|
|
that specify their own ssh command.
|
|
|
|
|
|
|
|
|
|
|
|
=item B<--xargs>
|
|
|
|
|
2011-07-10 14:33:33 +00:00
|
|
|
Multiple arguments. Insert as many arguments as the command line
|
|
|
|
length permits.
|
|
|
|
|
|
|
|
If B<{}> is not used the arguments will be appended to the
|
|
|
|
line. If B<{}> is used multiple times each B<{}> will be replaced
|
|
|
|
with all the arguments.
|
|
|
|
|
|
|
|
Support for B<--xargs> with B<--sshlogin> is limited and may fail.
|
|
|
|
|
|
|
|
See also B<-X> for context replace. If in doubt use B<-X> as that will
|
|
|
|
most likely do what is needed.
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<-m>
|
|
|
|
|
2011-06-27 21:21:26 +00:00
|
|
|
Multiple arguments. Insert as many arguments as the command line
|
|
|
|
length permits. If multiple jobs are being run in parallel: distribute
|
2016-01-01 14:12:43 +00:00
|
|
|
the arguments evenly among the jobs. Use B<-j1> or B<--xargs> to avoid this.
|
2011-06-27 21:21:26 +00:00
|
|
|
|
|
|
|
If B<{}> is not used the arguments will be appended to the
|
2010-12-06 23:30:08 +00:00
|
|
|
line. If B<{}> is used multiple times each B<{}> will be replaced
|
|
|
|
with all the arguments.
|
|
|
|
|
|
|
|
Support for B<-m> with B<--sshlogin> is limited and may fail.
|
|
|
|
|
|
|
|
See also B<-X> for context replace. If in doubt use B<-X> as that will
|
|
|
|
most likely do what is needed.
|
|
|
|
|
|
|
|
|
2016-01-06 15:22:30 +00:00
|
|
|
=item B<--memfree> I<size>
|
2015-01-21 21:24:23 +00:00
|
|
|
|
|
|
|
Minimum memory free when starting another job. The I<size> can be
|
|
|
|
postfixed with K, M, G, T, P, k, m, g, t, or p which would multiply
|
|
|
|
the size with 1024, 1048576, 1073741824, 1099511627776,
|
|
|
|
1125899906842624, 1000, 1000000, 1000000000, 1000000000000, or
|
2016-01-01 14:12:43 +00:00
|
|
|
1000000000000000, respectively.
|
2015-01-21 21:24:23 +00:00
|
|
|
|
|
|
|
If the jobs take up very different amount of RAM, GNU B<parallel> will
|
|
|
|
only start as many as there is memory for. If less than I<size> bytes
|
|
|
|
are free, no more jobs will be started. If less than 50% I<size> bytes
|
|
|
|
are free, the youngest job will be killed, and put back on the queue
|
|
|
|
to be run later.
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
B<--retries> must be set to determine how many times GNU B<parallel>
|
|
|
|
should retry a given job.
|
|
|
|
|
2015-01-21 21:24:23 +00:00
|
|
|
|
2011-08-21 23:01:57 +00:00
|
|
|
=item B<--minversion> I<version>
|
2011-06-05 16:27:50 +00:00
|
|
|
|
|
|
|
Print the version GNU B<parallel> and exit. If the current version of
|
|
|
|
GNU B<parallel> is less than I<version> the exit code is
|
|
|
|
255. Otherwise it is 0.
|
|
|
|
|
|
|
|
This is useful for scripts that depend on features only available from
|
|
|
|
a certain version of GNU B<parallel>.
|
|
|
|
|
|
|
|
|
2014-10-24 09:30:39 +00:00
|
|
|
=item B<--nonall>
|
2011-06-07 20:57:50 +00:00
|
|
|
|
|
|
|
B<--onall> with no arguments. Run the command on all computers given
|
|
|
|
with B<--sshlogin> but take no arguments. GNU B<parallel> will log
|
|
|
|
into B<--jobs> number of computers in parallel and run the job on the
|
|
|
|
computer. B<-j> adjusts how many computers to log into in parallel.
|
|
|
|
|
|
|
|
This is useful for running the same command (e.g. uptime) on a list of
|
|
|
|
servers.
|
|
|
|
|
|
|
|
|
2016-03-16 23:50:45 +00:00
|
|
|
=item B<--onall>
|
2011-05-26 21:19:58 +00:00
|
|
|
|
|
|
|
Run all the jobs on all computers given with B<--sshlogin>. GNU
|
|
|
|
B<parallel> will log into B<--jobs> number of computers in parallel
|
|
|
|
and run one job at a time on the computer. The order of the jobs will
|
2014-12-29 00:16:32 +00:00
|
|
|
not be changed, but some computers may finish before others.
|
2011-05-26 21:19:58 +00:00
|
|
|
|
2011-05-28 14:33:22 +00:00
|
|
|
When using B<--group> the output will be grouped by each server, so
|
|
|
|
all the output from one server will be grouped together.
|
|
|
|
|
2014-12-29 00:16:32 +00:00
|
|
|
B<--joblog> will contain an entry for each job on each server, so
|
|
|
|
there will be several job sequence 1.
|
|
|
|
|
2011-05-26 21:19:58 +00:00
|
|
|
|
2014-01-22 02:06:39 +00:00
|
|
|
=item B<--output-as-files>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2014-01-22 02:06:39 +00:00
|
|
|
=item B<--outputasfiles>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2014-01-22 02:06:39 +00:00
|
|
|
=item B<--files>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
|
|
|
Instead of printing the output to stdout (standard output) the output
|
|
|
|
of each job is saved in a file and the filename is then printed.
|
|
|
|
|
2014-11-15 14:25:19 +00:00
|
|
|
See also: B<--results>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--pipe>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--spreadstdin>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-05-26 21:19:58 +00:00
|
|
|
Spread input to jobs on stdin (standard input). Read a block of data
|
|
|
|
from stdin (standard input) and give one block of data as input to one
|
|
|
|
job.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-01-27 21:56:59 +00:00
|
|
|
The block size is determined by B<--block>. The strings B<--recstart>
|
|
|
|
and B<--recend> tell GNU B<parallel> how a record starts and/or
|
|
|
|
ends. The block read will have the final partial record removed before
|
|
|
|
the block is passed on to the job. The partial record will be
|
2011-01-22 22:40:15 +00:00
|
|
|
prepended to next block.
|
|
|
|
|
|
|
|
If B<--recstart> is given this will be used to split at record start.
|
|
|
|
|
|
|
|
If B<--recend> is given this will be used to split at record end.
|
|
|
|
|
|
|
|
If both B<--recstart> and B<--recend> are given both will have to
|
|
|
|
match to find a split position.
|
|
|
|
|
|
|
|
If neither B<--recstart> nor B<--recend> are given B<--recend>
|
|
|
|
defaults to '\n'. To have no record separator use B<--recend "">.
|
|
|
|
|
2011-01-27 21:56:59 +00:00
|
|
|
B<--files> is often used with B<--pipe>.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2015-05-20 19:09:33 +00:00
|
|
|
B<--pipe> maxes out at around 1 GB/s input, and 100 MB/s output. If
|
|
|
|
performance is important use B<--pipepart>.
|
|
|
|
|
2016-05-25 22:13:48 +00:00
|
|
|
See also: B<--recstart>, B<--recend>, B<--fifo>, B<--cat>,
|
|
|
|
B<--pipepart>, B<--files>.
|
2014-04-22 10:03:41 +00:00
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--pipepart>
|
2014-04-22 10:03:41 +00:00
|
|
|
|
|
|
|
Pipe parts of a physical file. B<--pipepart> works similar to
|
2016-05-25 22:13:48 +00:00
|
|
|
B<--pipe>, but is much faster.
|
|
|
|
|
|
|
|
B<--pipepart> has a few limitations:
|
2014-04-22 10:03:41 +00:00
|
|
|
|
|
|
|
=over 3
|
|
|
|
|
|
|
|
=item Z<>*
|
|
|
|
|
2016-07-04 02:26:57 +00:00
|
|
|
The file must be a normal file or a block device (technically it must
|
|
|
|
be seekable) and must be given using B<-a> or B<::::>. The file cannot
|
|
|
|
be a pipe or a fifo as they are not seekable.
|
|
|
|
|
|
|
|
If using a block device with lot of NUL bytes, remember to set
|
|
|
|
B<--recend ''>.
|
2014-04-22 10:03:41 +00:00
|
|
|
|
|
|
|
=item Z<>*
|
|
|
|
|
2014-07-15 16:02:58 +00:00
|
|
|
Record counting (B<-N>) and line counting (B<-L>/B<-l>) do not work.
|
2014-04-22 10:03:41 +00:00
|
|
|
|
|
|
|
=back
|
|
|
|
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2013-01-21 22:59:44 +00:00
|
|
|
=item B<--plain>
|
2012-08-08 19:25:18 +00:00
|
|
|
|
2014-03-21 21:39:54 +00:00
|
|
|
Ignore any B<--profile>, $PARALLEL, and ~/.parallel/config to get full
|
|
|
|
control on the command line (used by GNU B<parallel> internally when
|
|
|
|
called with B<--sshlogin>).
|
2012-08-08 16:38:29 +00:00
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--plus>
|
2014-08-07 18:20:37 +00:00
|
|
|
|
|
|
|
Activate additional replacement strings: {+/} {+.} {+..} {+...} {..}
|
2015-10-18 13:18:30 +00:00
|
|
|
{...} {/..} {/...} {##}. The idea being that '{+foo}' matches the opposite of
|
2014-08-07 18:20:37 +00:00
|
|
|
'{foo}' and {} = {+/}/{/} = {.}.{+.} = {+/}/{/.}.{+.} = {..}.{+..} =
|
|
|
|
{+/}/{/..}.{+..} = {...}.{+...} = {+/}/{/...}.{+...}
|
|
|
|
|
2015-10-18 13:18:30 +00:00
|
|
|
B<{##}> is the number of jobs to be run. It is incompatible with
|
|
|
|
B<-X>/B<-m>/B<--xargs>.
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
The following dynamic replacement strings are also activated. They are
|
|
|
|
inspired by bash's parameter expansion:
|
|
|
|
|
|
|
|
{:-str} str if the value is empty
|
|
|
|
{:num} remove the first num characters
|
|
|
|
{:num1:num2} characters from num1 to num2
|
|
|
|
{#str} remove prefix str
|
|
|
|
{%str} remove postfix str
|
|
|
|
{/str1/str2} replace str1 with str2
|
|
|
|
{^str} uppercase str if found at the start
|
|
|
|
{^^str} uppercase str
|
|
|
|
{,str} lowercase str if found at the start
|
|
|
|
{,,str} lowercase str
|
|
|
|
|
2014-08-07 18:20:37 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--progress>
|
|
|
|
|
|
|
|
Show progress of computations. List the computers involved in the task
|
|
|
|
with number of CPU cores detected and the max number of jobs to
|
|
|
|
run. After that show progress for each computer: number of running
|
|
|
|
jobs, number of completed jobs, and percentage of all jobs done by
|
|
|
|
this computer. The percentage will only be available after all jobs
|
|
|
|
have been scheduled as GNU B<parallel> only read the next job when
|
|
|
|
ready to schedule it - this is to avoid wasting time and memory by
|
|
|
|
reading everything at startup.
|
|
|
|
|
|
|
|
By sending GNU B<parallel> SIGUSR2 you can toggle turning on/off
|
|
|
|
B<--progress> on a running GNU B<parallel> process.
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
See also B<--eta> and B<--bar>.
|
2011-06-16 12:47:55 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-06-22 12:50:48 +00:00
|
|
|
=item B<--max-args>=I<max-args>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-06-22 12:50:48 +00:00
|
|
|
=item B<-n> I<max-args>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Use at most I<max-args> arguments per command line. Fewer than
|
|
|
|
I<max-args> arguments will be used if the size (see the B<-s> option)
|
|
|
|
is exceeded, unless the B<-x> option is given, in which case
|
|
|
|
GNU B<parallel> will exit.
|
|
|
|
|
2011-02-23 15:22:08 +00:00
|
|
|
B<-n 0> means read one argument, but insert 0 arguments on the command
|
|
|
|
line.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
Implies B<-X> unless B<-m> is set.
|
|
|
|
|
|
|
|
|
2013-06-22 12:50:48 +00:00
|
|
|
=item B<--max-replace-args>=I<max-args>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-06-22 12:50:48 +00:00
|
|
|
=item B<-N> I<max-args>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Use at most I<max-args> arguments per command line. Like B<-n> but
|
|
|
|
also makes replacement strings B<{1}> .. B<{>I<max-args>B<}> that
|
|
|
|
represents argument 1 .. I<max-args>. If too few args the B<{>I<n>B<}> will
|
|
|
|
be empty.
|
|
|
|
|
2011-02-23 15:22:08 +00:00
|
|
|
B<-N 0> means read one argument, but insert 0 arguments on the command
|
|
|
|
line.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
This will set the owner of the homedir to the user:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
tr ':' '\n' < /etc/passwd | parallel -N7 chown {1} {6}
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-06-11 23:19:29 +00:00
|
|
|
Implies B<-X> unless B<-m> or B<--pipe> is set.
|
2011-01-24 19:06:30 +00:00
|
|
|
|
|
|
|
When used with B<--pipe> B<-N> is the number of records to read. This
|
2013-03-03 12:45:31 +00:00
|
|
|
is somewhat slower than B<--block>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--max-line-length-allowed>
|
|
|
|
|
2012-03-12 22:38:38 +00:00
|
|
|
Print the maximal number of characters allowed on the command line and
|
2010-12-06 23:30:08 +00:00
|
|
|
exit (used by GNU B<parallel> itself to determine the line length
|
|
|
|
on remote computers).
|
|
|
|
|
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--number-of-cpus>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Print the number of physical CPUs and exit (used by GNU B<parallel>
|
|
|
|
itself to determine the number of physical CPUs on remote computers).
|
|
|
|
|
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--number-of-cores>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Print the number of CPU cores and exit (used by GNU B<parallel> itself
|
|
|
|
to determine the number of CPU cores on remote computers).
|
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<--no-keep-order>
|
2015-01-21 21:24:23 +00:00
|
|
|
|
|
|
|
Overrides an earlier B<--keep-order> (e.g. if set in
|
|
|
|
B<~/.parallel/config>).
|
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--nice> I<niceness>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Run the command at this niceness. For simple commands you can just add
|
|
|
|
B<nice> in front of the command. But if the command consists of more
|
|
|
|
sub commands (Like: ls|wc) then prepending B<nice> will not always
|
2014-11-11 14:51:19 +00:00
|
|
|
work. B<--nice> will make sure all sub commands are niced - even on
|
|
|
|
remote servers.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--interactive>
|
|
|
|
|
|
|
|
=item B<-p>
|
|
|
|
|
|
|
|
Prompt the user about whether to run each command line and read a line
|
|
|
|
from the terminal. Only run the command line if the response starts
|
|
|
|
with 'y' or 'Y'. Implies B<-t>.
|
|
|
|
|
|
|
|
|
2014-08-22 22:39:59 +00:00
|
|
|
=item B<--parens> I<parensstring>
|
2014-07-14 16:25:45 +00:00
|
|
|
|
2016-05-22 12:08:47 +00:00
|
|
|
Define start and end parenthesis for B<{= perl expression =}>. The
|
2014-07-14 16:25:45 +00:00
|
|
|
left and the right parenthesis can be multiple characters and are
|
2016-05-22 12:08:47 +00:00
|
|
|
assumed to be the same length. The default is B<{==}> giving B<{=> as
|
|
|
|
the start parenthesis and B<=}> as the end parenthesis.
|
2014-07-14 16:25:45 +00:00
|
|
|
|
|
|
|
Another useful setting is B<,,,,> which would make both parenthesis
|
|
|
|
B<,,>:
|
|
|
|
|
|
|
|
parallel --parens ,,,, echo foo is ,,s/I/O/g,, ::: FII
|
|
|
|
|
|
|
|
See also: B<--rpl> B<{= perl expression =}>
|
|
|
|
|
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<--profile> I<profilename>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-09-23 14:23:55 +00:00
|
|
|
=item B<-J> I<profilename>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Use profile I<profilename> for options. This is useful if you want to
|
|
|
|
have multiple profiles. You could have one profile for running jobs in
|
2010-12-21 17:08:16 +00:00
|
|
|
parallel on the local computer and a different profile for running jobs
|
|
|
|
on remote computers. See the section PROFILE FILES for examples.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
I<profilename> corresponds to the file ~/.parallel/I<profilename>.
|
|
|
|
|
2011-10-13 21:58:02 +00:00
|
|
|
You can give multiple profiles by repeating B<--profile>. If parts of
|
|
|
|
the profiles conflict, the later ones will be used.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
Default: config
|
|
|
|
|
2011-10-13 21:58:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--quote>
|
|
|
|
|
|
|
|
=item B<-q>
|
|
|
|
|
|
|
|
Quote I<command>. This will quote the command line so special
|
|
|
|
characters are not interpreted by the shell. See the section
|
|
|
|
QUOTING. Most people will never need this. Quoting is disabled by
|
|
|
|
default.
|
|
|
|
|
|
|
|
|
|
|
|
=item B<--no-run-if-empty>
|
|
|
|
|
|
|
|
=item B<-r>
|
|
|
|
|
|
|
|
If the stdin (standard input) only contains whitespace, do not run the command.
|
|
|
|
|
2011-09-09 19:15:00 +00:00
|
|
|
If used with B<--pipe> this is slow.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-05-22 12:53:33 +00:00
|
|
|
=item B<--noswap>
|
|
|
|
|
|
|
|
Do not start new jobs on a given computer if there is both swap-in and
|
|
|
|
swap-out activity.
|
|
|
|
|
|
|
|
The swap activity is only sampled every 10 seconds as the sampling
|
|
|
|
takes 1 second to do.
|
|
|
|
|
|
|
|
Swap activity is computed as (swap-in)*(swap-out) which in practice is
|
|
|
|
a good value: swapping out is not a problem, swapping in is not a
|
|
|
|
problem, but both swapping in and out usually indicates a problem.
|
|
|
|
|
2015-03-28 11:14:30 +00:00
|
|
|
B<--memfree> may give better results, so try using that first.
|
|
|
|
|
2014-05-22 12:53:33 +00:00
|
|
|
|
2013-10-21 20:31:52 +00:00
|
|
|
=item B<--record-env>
|
2013-08-14 18:11:00 +00:00
|
|
|
|
2013-08-15 17:38:39 +00:00
|
|
|
Record current environment variables in ~/.parallel/ignored_vars. This
|
2013-08-14 18:11:00 +00:00
|
|
|
is useful before using B<--env _>.
|
|
|
|
|
|
|
|
See also B<--env>.
|
|
|
|
|
|
|
|
|
2011-05-05 18:50:53 +00:00
|
|
|
=item B<--recstart> I<startstring>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-05-05 18:50:53 +00:00
|
|
|
=item B<--recend> I<endstring>
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-01-27 21:56:59 +00:00
|
|
|
If B<--recstart> is given I<startstring> will be used to split at record start.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-01-27 21:56:59 +00:00
|
|
|
If B<--recend> is given I<endstring> will be used to split at record end.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-12-09 22:25:20 +00:00
|
|
|
If both B<--recstart> and B<--recend> are given the combined string
|
|
|
|
I<endstring>I<startstring> will have to match to find a split
|
2011-02-02 15:36:29 +00:00
|
|
|
position. This is useful if either I<startstring> or I<endstring>
|
2011-01-24 19:06:30 +00:00
|
|
|
match in the middle of a record.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-01-24 19:06:30 +00:00
|
|
|
If neither B<--recstart> nor B<--recend> are given then B<--recend>
|
2011-01-22 22:40:15 +00:00
|
|
|
defaults to '\n'. To have no record separator use B<--recend "">.
|
|
|
|
|
2011-01-24 19:06:30 +00:00
|
|
|
B<--recstart> and B<--recend> are used with B<--pipe>.
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-01-27 21:56:59 +00:00
|
|
|
Use B<--regexp> to interpret B<--recstart> and B<--recend> as regular
|
|
|
|
expressions. This is slow, however.
|
|
|
|
|
|
|
|
|
2011-08-21 23:01:57 +00:00
|
|
|
=item B<--regexp>
|
2011-01-27 21:56:59 +00:00
|
|
|
|
|
|
|
Use B<--regexp> to interpret B<--recstart> and B<--recend> as regular
|
|
|
|
expressions. This is slow, however.
|
|
|
|
|
2011-01-22 22:40:15 +00:00
|
|
|
|
2011-05-05 18:50:53 +00:00
|
|
|
=item B<--remove-rec-sep>
|
2011-01-25 23:34:08 +00:00
|
|
|
|
2011-05-05 18:50:53 +00:00
|
|
|
=item B<--removerecsep>
|
2011-01-25 23:34:08 +00:00
|
|
|
|
2011-05-05 18:50:53 +00:00
|
|
|
=item B<--rrs>
|
2011-01-25 23:34:08 +00:00
|
|
|
|
|
|
|
Remove the text matched by B<--recstart> and B<--recend> before piping
|
|
|
|
it to the command.
|
|
|
|
|
|
|
|
Only used with B<--pipe>.
|
|
|
|
|
2011-02-02 15:36:29 +00:00
|
|
|
|
2017-03-02 21:40:46 +00:00
|
|
|
=item B<--results> I<name> (beta testing)
|
2012-09-30 22:04:52 +00:00
|
|
|
|
2017-03-02 21:40:46 +00:00
|
|
|
=item B<--res> I<name> (beta testing)
|
2012-09-30 22:04:52 +00:00
|
|
|
|
2016-12-18 10:14:06 +00:00
|
|
|
Save the output into files.
|
|
|
|
|
2017-01-27 22:15:25 +00:00
|
|
|
B<Simple string output dir>
|
2016-12-18 10:14:06 +00:00
|
|
|
|
2017-01-27 22:15:25 +00:00
|
|
|
If I<name> does not contain replacement strings and does not end in
|
|
|
|
B<.csv/.tsv>, the output will be stored in a directory tree rooted at
|
|
|
|
I<name>. Within this directory tree, each command will result in
|
|
|
|
three files: I<name>/<ARGS>/stdout and I<name>/<ARGS>/stderr,
|
|
|
|
I<name>/<ARGS>/seq, where <ARGS> is a sequence of directories
|
|
|
|
representing the header of the input source (if using B<--header :>)
|
|
|
|
or the number of the input source and corresponding values.
|
2012-09-30 22:04:52 +00:00
|
|
|
|
|
|
|
E.g:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --header : --results foo echo {a} {b} \
|
|
|
|
::: a I II ::: b III IIII
|
2012-09-30 22:04:52 +00:00
|
|
|
|
2012-10-17 00:09:03 +00:00
|
|
|
will generate the files:
|
2012-09-30 22:04:52 +00:00
|
|
|
|
2017-01-06 18:10:20 +00:00
|
|
|
foo/a/II/b/III/seq
|
2014-04-19 08:11:32 +00:00
|
|
|
foo/a/II/b/III/stderr
|
2012-12-22 06:02:06 +00:00
|
|
|
foo/a/II/b/III/stdout
|
2017-01-06 18:10:20 +00:00
|
|
|
foo/a/II/b/IIII/seq
|
2014-04-19 08:11:32 +00:00
|
|
|
foo/a/II/b/IIII/stderr
|
2012-12-22 06:02:06 +00:00
|
|
|
foo/a/II/b/IIII/stdout
|
2017-01-06 18:10:20 +00:00
|
|
|
foo/a/I/b/III/seq
|
|
|
|
foo/a/I/b/III/stderr
|
|
|
|
foo/a/I/b/III/stdout
|
|
|
|
foo/a/I/b/IIII/seq
|
|
|
|
foo/a/I/b/IIII/stderr
|
|
|
|
foo/a/I/b/IIII/stdout
|
2012-09-30 22:04:52 +00:00
|
|
|
|
|
|
|
and
|
|
|
|
|
2012-12-22 06:02:06 +00:00
|
|
|
parallel --results foo echo {1} {2} ::: I II ::: III IIII
|
2012-09-30 22:04:52 +00:00
|
|
|
|
2012-10-17 00:09:03 +00:00
|
|
|
will generate the files:
|
2012-09-30 22:04:52 +00:00
|
|
|
|
2017-01-06 18:10:20 +00:00
|
|
|
foo/1/II/2/III/seq
|
2014-04-19 08:11:32 +00:00
|
|
|
foo/1/II/2/III/stderr
|
2012-12-22 06:02:06 +00:00
|
|
|
foo/1/II/2/III/stdout
|
2017-01-06 18:10:20 +00:00
|
|
|
foo/1/II/2/IIII/seq
|
2014-04-19 08:11:32 +00:00
|
|
|
foo/1/II/2/IIII/stderr
|
2012-12-22 06:02:06 +00:00
|
|
|
foo/1/II/2/IIII/stdout
|
2017-01-06 18:10:20 +00:00
|
|
|
foo/1/I/2/III/seq
|
|
|
|
foo/1/I/2/III/stderr
|
|
|
|
foo/1/I/2/III/stdout
|
|
|
|
foo/1/I/2/IIII/seq
|
|
|
|
foo/1/I/2/IIII/stderr
|
|
|
|
foo/1/I/2/IIII/stdout
|
2012-09-30 22:04:52 +00:00
|
|
|
|
2016-06-27 19:00:19 +00:00
|
|
|
|
2017-01-27 22:15:25 +00:00
|
|
|
B<CSV file output>
|
|
|
|
|
|
|
|
If I<name> ends in B<.csv>/B<.tsv> the output will be a CSV-file
|
|
|
|
named I<name>.
|
|
|
|
|
|
|
|
B<.csv> gives a comma separated value file. B<.tsv> gives a TAB
|
|
|
|
separated value file.
|
|
|
|
|
|
|
|
B<-.csv>/B<-.tsv> are special: It will give the file on stdout
|
|
|
|
(standard output).
|
|
|
|
|
|
|
|
|
|
|
|
B<Replacement string output file>
|
|
|
|
|
|
|
|
If I<name> contains a replacement string and the replaced result does
|
|
|
|
not end in /, then the standard output will be stored in a file named
|
|
|
|
by this result. Standard error will be stored in the same file name
|
|
|
|
with '.err' added, and the sequence number will be stored in the same
|
|
|
|
file name with '.seq' added.
|
|
|
|
|
|
|
|
E.g.
|
|
|
|
|
|
|
|
parallel --results my_{} echo ::: foo bar baz
|
2016-06-27 19:00:19 +00:00
|
|
|
|
|
|
|
will generate the files:
|
|
|
|
|
2017-01-27 22:15:25 +00:00
|
|
|
my_bar
|
|
|
|
my_bar.err
|
|
|
|
my_bar.seq
|
|
|
|
my_baz
|
|
|
|
my_baz.err
|
|
|
|
my_baz.seq
|
|
|
|
my_foo
|
|
|
|
my_foo.err
|
|
|
|
my_foo.seq
|
|
|
|
|
|
|
|
|
|
|
|
B<Replacement string output dir>
|
|
|
|
|
|
|
|
If I<name> contains a replacement string and the replaced result ends
|
|
|
|
in /, then output files will be stored in the resulting dir.
|
|
|
|
|
|
|
|
E.g.
|
|
|
|
|
|
|
|
parallel --results my_{}/ echo ::: foo bar baz
|
|
|
|
|
|
|
|
will generate the files:
|
|
|
|
|
|
|
|
my_bar/seq
|
|
|
|
my_bar/stderr
|
|
|
|
my_bar/stdout
|
|
|
|
my_baz/seq
|
|
|
|
my_baz/stderr
|
|
|
|
my_baz/stdout
|
|
|
|
my_foo/seq
|
|
|
|
my_foo/stderr
|
|
|
|
my_foo/stdout
|
2015-03-28 11:14:30 +00:00
|
|
|
|
|
|
|
See also B<--files>, B<--tag>, B<--header>, B<--joblog>.
|
2012-09-30 22:04:52 +00:00
|
|
|
|
|
|
|
|
2014-01-22 02:06:39 +00:00
|
|
|
=item B<--resume>
|
2012-01-07 02:29:48 +00:00
|
|
|
|
2013-11-22 22:31:46 +00:00
|
|
|
Resumes from the last unfinished job. By reading B<--joblog> or the
|
|
|
|
B<--results> dir GNU B<parallel> will figure out the last unfinished
|
|
|
|
job and continue from there. As GNU B<parallel> only looks at the
|
|
|
|
sequence numbers in B<--joblog> then the input, the command, and
|
|
|
|
B<--joblog> all have to remain unchanged; otherwise GNU B<parallel>
|
|
|
|
may run wrong commands.
|
2012-01-07 02:29:48 +00:00
|
|
|
|
2016-07-22 18:39:12 +00:00
|
|
|
See also B<--joblog>, B<--results>, B<--resume-failed>, B<--retries>.
|
2013-02-17 23:59:59 +00:00
|
|
|
|
|
|
|
|
2013-05-21 22:29:41 +00:00
|
|
|
=item B<--resume-failed>
|
2013-02-17 23:59:59 +00:00
|
|
|
|
|
|
|
Retry all failed and resume from the last unfinished job. By reading
|
|
|
|
B<--joblog> GNU B<parallel> will figure out the failed jobs and run
|
|
|
|
those again. After that it will resume last unfinished job and
|
|
|
|
continue from there. As GNU B<parallel> only looks at the sequence
|
|
|
|
numbers in B<--joblog> then the input, the command, and B<--joblog>
|
|
|
|
all have to remain unchanged; otherwise GNU B<parallel> may run wrong
|
|
|
|
commands.
|
|
|
|
|
2016-07-22 18:39:12 +00:00
|
|
|
See also B<--joblog>, B<--resume>, B<--retry-failed>, B<--retries>.
|
2012-01-07 02:29:48 +00:00
|
|
|
|
|
|
|
|
2015-07-29 00:19:51 +00:00
|
|
|
=item B<--retry-failed>
|
2015-05-20 19:09:33 +00:00
|
|
|
|
|
|
|
Retry all failed jobs in joblog. By reading B<--joblog> GNU
|
|
|
|
B<parallel> will figure out the failed jobs and run those again.
|
|
|
|
|
2016-07-22 18:39:12 +00:00
|
|
|
B<--retry-failed> ignores the command and arguments on the command
|
|
|
|
line: It only looks at the joblog.
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
B<Differences between --resume, --resume-failed, --retry-failed>
|
2016-07-22 18:39:12 +00:00
|
|
|
|
|
|
|
In this example B<exit {= $_%=2 =}> will cause every other job to fail.
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
timeout -k 1 4 parallel --joblog log -j10 \
|
|
|
|
'sleep {}; exit {= $_%=2 =}' ::: {10..1}
|
2016-07-22 18:39:12 +00:00
|
|
|
|
|
|
|
4 jobs completed. 2 failed:
|
|
|
|
|
|
|
|
Seq [...] Exitval Signal Command
|
|
|
|
10 [...] 1 0 sleep 1; exit 1
|
|
|
|
9 [...] 0 0 sleep 2; exit 0
|
|
|
|
8 [...] 1 0 sleep 3; exit 1
|
|
|
|
7 [...] 0 0 sleep 4; exit 0
|
|
|
|
|
|
|
|
B<--resume> does not care about the Exitval, but only looks at Seq. If
|
|
|
|
the Seq is run, it will not be run again. So if needed, you can change
|
|
|
|
the command for the seqs not run yet:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --resume --joblog log -j10 \
|
|
|
|
'sleep .{}; exit {= $_%=2 =}' ::: {10..1}
|
2016-07-22 18:39:12 +00:00
|
|
|
|
|
|
|
Seq [...] Exitval Signal Command
|
|
|
|
[... as above ...]
|
|
|
|
1 [...] 0 0 sleep .10; exit 0
|
|
|
|
6 [...] 1 0 sleep .5; exit 1
|
|
|
|
5 [...] 0 0 sleep .6; exit 0
|
|
|
|
4 [...] 1 0 sleep .7; exit 1
|
|
|
|
3 [...] 0 0 sleep .8; exit 0
|
|
|
|
2 [...] 1 0 sleep .9; exit 1
|
|
|
|
|
|
|
|
B<--resume-failed> cares about the Exitval, but also only looks at Seq
|
|
|
|
to figure out which commands to run. Again this means you can change
|
|
|
|
the command, but not the arguments. It will run the failed seqs and
|
|
|
|
the seqs not yet run:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --resume-failed --joblog log -j10 \
|
|
|
|
'echo {};sleep .{}; exit {= $_%=3 =}' ::: {10..1}
|
2016-07-22 18:39:12 +00:00
|
|
|
|
|
|
|
Seq [...] Exitval Signal Command
|
|
|
|
[... as above ...]
|
|
|
|
10 [...] 1 0 echo 1;sleep .1; exit 1
|
|
|
|
8 [...] 0 0 echo 3;sleep .3; exit 0
|
|
|
|
6 [...] 2 0 echo 5;sleep .5; exit 2
|
|
|
|
4 [...] 1 0 echo 7;sleep .7; exit 1
|
|
|
|
2 [...] 0 0 echo 9;sleep .9; exit 0
|
|
|
|
|
|
|
|
B<--retry-failed> cares about the Exitval, but takes the command from
|
|
|
|
the joblog. It ignores any arguments or commands given on the command
|
|
|
|
line:
|
|
|
|
|
|
|
|
parallel --retry-failed --joblog log -j10 this part is ignored
|
|
|
|
|
|
|
|
Seq [...] Exitval Signal Command
|
|
|
|
[... as above ...]
|
|
|
|
10 [...] 1 0 echo 1;sleep .1; exit 1
|
|
|
|
6 [...] 2 0 echo 5;sleep .5; exit 2
|
|
|
|
4 [...] 1 0 echo 7;sleep .7; exit 1
|
2015-05-20 19:09:33 +00:00
|
|
|
|
2016-07-22 18:39:12 +00:00
|
|
|
See also B<--joblog>, B<--resume>, B<--resume-failed>, B<--retries>.
|
2015-05-20 19:09:33 +00:00
|
|
|
|
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--retries> I<n>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-05-31 06:42:56 +00:00
|
|
|
If a job fails, retry it on another computer on which it has not
|
|
|
|
failed. Do this I<n> times. If there are fewer than I<n> computers in
|
|
|
|
B<--sshlogin> GNU B<parallel> will re-use all the computers. This is
|
|
|
|
useful if some jobs fail for no apparent reason (such as network
|
|
|
|
failure).
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--return> I<filename>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
Transfer files from remote computers. B<--return> is used with
|
|
|
|
B<--sshlogin> when the arguments are files on the remote computers. When
|
2010-12-06 23:30:08 +00:00
|
|
|
processing is done the file I<filename> will be transferred
|
2010-12-21 17:08:16 +00:00
|
|
|
from the remote computer using B<rsync> and will be put relative to
|
2010-12-06 23:30:08 +00:00
|
|
|
the default login dir. E.g.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo foo/bar.txt | parallel --return {.}.out \
|
|
|
|
--sshlogin server.example.com touch {.}.out
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
This will transfer the file I<$HOME/foo/bar.out> from the computer
|
2010-12-06 23:30:08 +00:00
|
|
|
I<server.example.com> to the file I<foo/bar.out> after running
|
|
|
|
B<touch foo/bar.out> on I<server.example.com>.
|
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
parallel -S server --trc out/./{}.out touch {}.out ::: in/file
|
|
|
|
|
|
|
|
This will transfer the file I<in/file.out> from the computer
|
|
|
|
I<server.example.com> to the files I<out/in/file.out> after running
|
|
|
|
B<touch in/file.out> on I<server>.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo /tmp/foo/bar.txt | parallel --return {.}.out \
|
|
|
|
--sshlogin server.example.com touch {.}.out
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
This will transfer the file I</tmp/foo/bar.out> from the computer
|
2010-12-06 23:30:08 +00:00
|
|
|
I<server.example.com> to the file I</tmp/foo/bar.out> after running
|
|
|
|
B<touch /tmp/foo/bar.out> on I<server.example.com>.
|
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
Multiple files can be transferred by repeating the option multiple
|
2010-12-06 23:30:08 +00:00
|
|
|
times:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo /tmp/foo/bar.txt | parallel \
|
|
|
|
--sshlogin server.example.com \
|
2010-12-06 23:30:08 +00:00
|
|
|
--return {.}.out --return {.}.out2 touch {.}.out {.}.out2
|
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
B<--return> is often used with B<--transferfile> and B<--cleanup>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
B<--return> is ignored when used with B<--sshlogin :> or when not used
|
|
|
|
with B<--sshlogin>.
|
|
|
|
|
|
|
|
|
2017-01-21 18:55:14 +00:00
|
|
|
=item B<--round-robin>
|
2013-07-20 15:33:26 +00:00
|
|
|
|
2017-01-21 18:55:14 +00:00
|
|
|
=item B<--round>
|
2013-07-20 15:33:26 +00:00
|
|
|
|
|
|
|
Normally B<--pipe> will give a single block to each instance of the
|
|
|
|
command. With B<--round-robin> all blocks will at random be written to
|
|
|
|
commands already running. This is useful if the command takes a long
|
|
|
|
time to initialize.
|
|
|
|
|
|
|
|
B<--keep-order> will not work with B<--round-robin> as it is
|
|
|
|
impossible to track which input block corresponds to which output.
|
|
|
|
|
2016-07-04 02:26:57 +00:00
|
|
|
B<--round-robin> implies B<--pipe>, except if B<--pipepart> is given.
|
2015-06-21 08:39:48 +00:00
|
|
|
|
2013-07-20 15:33:26 +00:00
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--rpl> 'I<tag> I<perl expression>'
|
2014-07-14 16:25:45 +00:00
|
|
|
|
|
|
|
Use I<tag> as a replacement string for I<perl expression>. This makes
|
|
|
|
it possible to define your own replacement strings. GNU B<parallel>'s
|
|
|
|
7 replacement strings are implemented as:
|
|
|
|
|
|
|
|
--rpl '{} '
|
2014-09-23 18:14:57 +00:00
|
|
|
--rpl '{#} 1 $_=$job->seq()'
|
|
|
|
--rpl '{%} 1 $_=$job->slot()'
|
2014-07-14 16:25:45 +00:00
|
|
|
--rpl '{/} s:.*/::'
|
2017-03-21 21:20:38 +00:00
|
|
|
--rpl '{//} $Global::use{"File::Basename"} ||=
|
|
|
|
eval "use File::Basename; 1;"; $_ = dirname($_);'
|
2014-07-14 16:25:45 +00:00
|
|
|
--rpl '{/.} s:.*/::; s:\.[^/.]+$::;'
|
|
|
|
--rpl '{.} s:\.[^/.]+$::'
|
|
|
|
|
2016-05-22 12:08:47 +00:00
|
|
|
The B<--plus> replacement strings are implemented as:
|
2015-11-29 23:47:21 +00:00
|
|
|
|
|
|
|
--rpl '{+/} s:/[^/]*$::'
|
|
|
|
--rpl '{+.} s:.*\.::'
|
|
|
|
--rpl '{+..} s:.*\.([^.]*\.):$1:'
|
|
|
|
--rpl '{+...} s:.*\.([^.]*\.[^.]*\.):$1:'
|
|
|
|
--rpl '{..} s:\.[^/.]+$::; s:\.[^/.]+$::'
|
|
|
|
--rpl '{...} s:\.[^/.]+$::; s:\.[^/.]+$::; s:\.[^/.]+$::'
|
|
|
|
--rpl '{/..} s:.*/::; s:\.[^/.]+$::; s:\.[^/.]+$::'
|
2017-03-21 21:20:38 +00:00
|
|
|
--rpl '{/...} s:.*/::;s:\.[^/.]+$::;s:\.[^/.]+$::;s:\.[^/.]+$::'
|
2015-11-29 23:47:21 +00:00
|
|
|
--rpl '{##} $_=total_jobs()'
|
2017-03-11 20:19:10 +00:00
|
|
|
--rpl '{:-(.+?)} $_ ||= $$1'
|
|
|
|
--rpl '{:(\d+?)} substr($_,0,$$1) = ""'
|
|
|
|
--rpl '{:(\d+?):(\d+?)} $_ = substr($_,$$1,$$2);'
|
|
|
|
--rpl '{#([^#].*?)} s/^$$1//;'
|
|
|
|
--rpl '{%(.+?)} s/$$1$//;'
|
2017-03-21 21:20:38 +00:00
|
|
|
--rpl '{/(.+?)/(.*?)} s/$$1/$$2/;'
|
|
|
|
--rpl '{^(.+?)} s/^($$1)/uc($1)/e;'
|
2017-03-11 20:19:10 +00:00
|
|
|
--rpl '{^^(.+?)} s/($$1)/uc($1)/eg;'
|
2017-03-21 21:20:38 +00:00
|
|
|
--rpl '{,(.+?)} s/^($$1)/lc($1)/e;'
|
2017-03-11 20:19:10 +00:00
|
|
|
--rpl '{,,(.+?)} s/($$1)/lc($1)/eg;'
|
2015-11-29 23:47:21 +00:00
|
|
|
|
|
|
|
|
2014-07-14 16:25:45 +00:00
|
|
|
If the user defined replacement string starts with '{' it can also be
|
|
|
|
used as a positional replacement string (like B<{2.}>).
|
|
|
|
|
|
|
|
It is recommended to only change $_ but you have full access to all
|
|
|
|
of GNU B<parallel>'s internal functions and data structures.
|
|
|
|
|
2014-07-15 13:58:31 +00:00
|
|
|
Here are a few examples:
|
|
|
|
|
|
|
|
Is the job sequence even or odd?
|
2017-02-05 01:46:29 +00:00
|
|
|
--rpl '{odd} $_ = seq() % 2 ? "odd" : "even"'
|
2016-05-22 12:08:47 +00:00
|
|
|
Pad job sequence with leading zeros to get equal width
|
2017-03-21 21:20:38 +00:00
|
|
|
--rpl '{0#} $f=1+int("".(log(total_jobs())/log(10)));
|
|
|
|
$_=sprintf("%0${f}d",seq())'
|
2016-05-22 12:08:47 +00:00
|
|
|
Job sequence counting from 0
|
2017-02-05 01:46:29 +00:00
|
|
|
--rpl '{#0} $_ = seq() - 1'
|
2016-07-22 18:39:12 +00:00
|
|
|
Job slot counting from 2
|
2017-02-05 01:46:29 +00:00
|
|
|
--rpl '{%1} $_ = slot() + 1'
|
2014-07-15 13:58:31 +00:00
|
|
|
|
2017-03-10 18:39:53 +00:00
|
|
|
You can have dynamic replacement strings by including parenthesis in
|
|
|
|
the replacement string and adding a regular expression between the
|
|
|
|
parenthesis. The matching string will be inserted as $$1:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --rpl '{%(.*?)} s/$$1//' echo {%.tar.gz} ::: my.tar.gz
|
2017-03-10 18:39:53 +00:00
|
|
|
|
|
|
|
You can even use multiple matches:
|
|
|
|
|
|
|
|
parallel --rpl '{@(\d+)\S(\d+)\S(\d+)}
|
|
|
|
if($$3 > 31) { ($$1,$$2,$$3) = ($$3,$$2,$$1) }
|
|
|
|
if($$2 > 12) { ($$1,$$2,$$3) = ($$1,$$3,$$2) }
|
|
|
|
$$1 = ($$1%100 + 1900); $_="$$1-$$2-$$3"
|
|
|
|
' echo {@99-12-31} {@12.31.99} {@31/12-1999} ::: a
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --rpl '{(.*?)/(.*?)} $_="$$2$_$$1"' \
|
|
|
|
echo {swap/these} ::: -middle-
|
2017-03-10 18:39:53 +00:00
|
|
|
|
2014-07-14 16:25:45 +00:00
|
|
|
See also: B<{= perl expression =}> B<--parens>
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--max-chars>=I<max-chars>
|
|
|
|
|
|
|
|
=item B<-s> I<max-chars>
|
|
|
|
|
|
|
|
Use at most I<max-chars> characters per command line, including the
|
|
|
|
command and initial-arguments and the terminating nulls at the ends of
|
|
|
|
the argument strings. The largest allowed value is system-dependent,
|
|
|
|
and is calculated as the argument length limit for exec, less the size
|
|
|
|
of your environment. The default value is the maximum.
|
|
|
|
|
|
|
|
Implies B<-X> unless B<-m> is set.
|
|
|
|
|
|
|
|
|
|
|
|
=item B<--show-limits>
|
|
|
|
|
|
|
|
Display the limits on the command-line length which are imposed by the
|
|
|
|
operating system and the B<-s> option. Pipe the input from /dev/null
|
|
|
|
(and perhaps specify --no-run-if-empty) if you don't want GNU B<parallel>
|
|
|
|
to do anything.
|
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<--semaphore>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Work as a counting semaphore. B<--semaphore> will cause GNU
|
|
|
|
B<parallel> to start I<command> in the background. When the number of
|
2015-05-06 22:40:36 +00:00
|
|
|
jobs given by B<--jobs> is reached, GNU B<parallel> will wait for one of
|
2010-12-06 23:30:08 +00:00
|
|
|
these to complete before starting another command.
|
|
|
|
|
|
|
|
B<--semaphore> implies B<--bg> unless B<--fg> is specified.
|
|
|
|
|
|
|
|
B<--semaphore> implies B<--semaphorename `tty`> unless
|
|
|
|
B<--semaphorename> is specified.
|
|
|
|
|
|
|
|
Used with B<--fg>, B<--wait>, and B<--semaphorename>.
|
|
|
|
|
|
|
|
The command B<sem> is an alias for B<parallel --semaphore>.
|
|
|
|
|
2013-08-14 18:11:00 +00:00
|
|
|
See also B<man sem>.
|
2011-06-25 07:22:05 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=item B<--semaphorename> I<name>
|
|
|
|
|
|
|
|
=item B<--id> I<name>
|
|
|
|
|
2011-06-25 07:22:05 +00:00
|
|
|
Use B<name> as the name of the semaphore. Default is the name of the
|
|
|
|
controlling tty (output from B<tty>).
|
|
|
|
|
|
|
|
The default normally works as expected when used interactively, but
|
|
|
|
when used in a script I<name> should be set. I<$$> or I<my_task_name>
|
|
|
|
are often a good value.
|
|
|
|
|
|
|
|
The semaphore is stored in ~/.parallel/semaphores/
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Implies B<--semaphore>.
|
|
|
|
|
2013-08-14 18:11:00 +00:00
|
|
|
See also B<man sem>.
|
2011-06-25 07:22:05 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<--semaphoretimeout> I<secs>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<--st> I<secs>
|
2015-01-03 13:48:01 +00:00
|
|
|
|
|
|
|
If I<secs> > 0: If the semaphore is not released within I<secs> seconds, take it anyway.
|
|
|
|
|
|
|
|
If I<secs> < 0: If the semaphore is not released within I<secs> seconds, exit.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Implies B<--semaphore>.
|
|
|
|
|
2013-08-14 18:11:00 +00:00
|
|
|
See also B<man sem>.
|
2011-06-25 07:22:05 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-04-08 19:57:19 +00:00
|
|
|
=item B<--seqreplace> I<replace-str>
|
|
|
|
|
|
|
|
Use the replacement string I<replace-str> instead of B<{#}> for
|
|
|
|
job sequence number.
|
|
|
|
|
|
|
|
|
2014-08-22 22:39:59 +00:00
|
|
|
=item B<--shebang>
|
2012-11-25 20:24:27 +00:00
|
|
|
|
2014-08-22 22:39:59 +00:00
|
|
|
=item B<--hashbang>
|
2012-11-25 20:24:27 +00:00
|
|
|
|
|
|
|
GNU B<parallel> can be called as a shebang (#!) command as the first
|
|
|
|
line of a script. The content of the file will be treated as
|
|
|
|
inputsource.
|
|
|
|
|
|
|
|
Like this:
|
|
|
|
|
|
|
|
#!/usr/bin/parallel --shebang -r traceroute
|
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
qubes-os.org
|
2012-11-25 20:24:27 +00:00
|
|
|
debian.org
|
|
|
|
freenetproject.org
|
|
|
|
|
|
|
|
B<--shebang> must be set as the first option.
|
|
|
|
|
2014-06-23 00:10:53 +00:00
|
|
|
On FreeBSD B<env> is needed:
|
|
|
|
|
|
|
|
#!/usr/bin/env -S parallel --shebang -r traceroute
|
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
qubes-os.org
|
2014-06-23 00:10:53 +00:00
|
|
|
debian.org
|
|
|
|
freenetproject.org
|
|
|
|
|
2015-01-02 10:33:40 +00:00
|
|
|
There are many limitations of shebang (#!) depending on your operating
|
|
|
|
system. See details on http://www.in-ulm.de/~mascheck/various/shebang/
|
|
|
|
|
2012-11-25 20:24:27 +00:00
|
|
|
|
2014-08-22 22:39:59 +00:00
|
|
|
=item B<--shebang-wrap>
|
2012-11-25 20:24:27 +00:00
|
|
|
|
|
|
|
GNU B<parallel> can parallelize scripts by wrapping the shebang
|
|
|
|
line. If the program can be run like this:
|
|
|
|
|
|
|
|
cat arguments | parallel the_program
|
|
|
|
|
|
|
|
then the script can be changed to:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
#!/usr/bin/parallel --shebang-wrap /original/parser --options
|
2012-11-25 20:24:27 +00:00
|
|
|
|
|
|
|
E.g.
|
|
|
|
|
|
|
|
#!/usr/bin/parallel --shebang-wrap /usr/bin/python
|
|
|
|
|
|
|
|
If the program can be run like this:
|
|
|
|
|
|
|
|
cat data | parallel --pipe the_program
|
|
|
|
|
|
|
|
then the script can be changed to:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
#!/usr/bin/parallel --shebang-wrap --pipe /orig/parser --opts
|
2012-11-25 20:24:27 +00:00
|
|
|
|
|
|
|
E.g.
|
|
|
|
|
|
|
|
#!/usr/bin/parallel --shebang-wrap --pipe /usr/bin/perl -w
|
|
|
|
|
|
|
|
B<--shebang-wrap> must be set as the first option.
|
|
|
|
|
|
|
|
|
2011-09-09 19:15:00 +00:00
|
|
|
=item B<--shellquote>
|
|
|
|
|
2011-09-16 13:26:17 +00:00
|
|
|
Does not run the command but quotes it. Useful for making quoted
|
2011-09-09 19:15:00 +00:00
|
|
|
composed commands for GNU B<parallel>.
|
|
|
|
|
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--shuf>
|
2015-04-21 22:08:50 +00:00
|
|
|
|
|
|
|
Shuffle jobs. When having multiple input sources it is hard to
|
|
|
|
randomize jobs. --shuf will generate all jobs, and shuffle them before
|
|
|
|
running them. This is useful to get a quick preview of the results
|
|
|
|
before running the full batch.
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--skip-first-line>
|
|
|
|
|
|
|
|
Do not use the first line of input (used by GNU B<parallel> itself
|
|
|
|
when called with B<--shebang>).
|
|
|
|
|
|
|
|
|
2016-03-20 22:57:25 +00:00
|
|
|
=item B<--sql> I<DBURL> (obsolete)
|
|
|
|
|
|
|
|
Use B<--sqlmaster> instead.
|
|
|
|
|
|
|
|
|
2017-03-02 21:40:46 +00:00
|
|
|
=item B<--sqlmaster> I<DBURL>
|
2016-01-01 14:12:43 +00:00
|
|
|
|
|
|
|
Submit jobs via SQL server. I<DBURL> must point to a table, which will
|
|
|
|
contain the same information as B<--joblog>, the values from the input
|
|
|
|
sources (stored in columns V1 .. Vn), and the output (stored in
|
|
|
|
columns Stdout and Stderr).
|
|
|
|
|
2016-12-07 13:33:50 +00:00
|
|
|
|
|
|
|
If I<DBURL> is prepended with '+' GNU B<parallel> assumes the table is
|
|
|
|
already made with the correct columns and appends the jobs to it.
|
|
|
|
|
|
|
|
If I<DBURL> is not prepended with '+' the table will be dropped and
|
|
|
|
created with the correct amount of V-columns unless
|
2016-01-01 14:12:43 +00:00
|
|
|
|
2016-03-20 22:57:25 +00:00
|
|
|
B<--sqlmaster> does not run any jobs, but it creates the values for
|
2016-12-07 13:33:50 +00:00
|
|
|
the jobs to be run. One or more B<--sqlworker> must be run to actually
|
|
|
|
execute the jobs.
|
|
|
|
|
|
|
|
If B<--wait> is set, GNU B<parallel> will wait for the jobs to
|
|
|
|
complete.
|
2016-01-01 14:12:43 +00:00
|
|
|
|
|
|
|
The format of a DBURL is:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
[sql:]vendor://[[user][:pwd]@][host][:port]/[db]/table
|
2016-01-01 14:12:43 +00:00
|
|
|
|
|
|
|
E.g.
|
|
|
|
|
|
|
|
sql:mysql://hr:hr@localhost:3306/hrdb/jobs
|
|
|
|
mysql://scott:tiger@my.example.com/pardb/paralleljobs
|
|
|
|
sql:oracle://scott:tiger@ora.example.com/xe/parjob
|
|
|
|
postgresql://scott:tiger@pg.example.com/pgdb/parjob
|
|
|
|
pg:///parjob
|
|
|
|
sqlite3:///pardb/parjob
|
|
|
|
|
|
|
|
It can also be an alias from ~/.sql/aliases:
|
|
|
|
|
|
|
|
:myalias mysql:///mydb/paralleljobs
|
|
|
|
|
|
|
|
|
2017-03-02 21:40:46 +00:00
|
|
|
=item B<--sqlandworker> I<DBURL>
|
2016-01-01 14:12:43 +00:00
|
|
|
|
2016-03-20 22:57:25 +00:00
|
|
|
Shorthand for: B<--sqlmaster> I<DBURL> B<--sqlworker> I<DBURL>.
|
2016-01-01 14:12:43 +00:00
|
|
|
|
|
|
|
|
2017-03-02 21:40:46 +00:00
|
|
|
=item B<--sqlworker> I<DBURL>
|
2016-01-01 14:12:43 +00:00
|
|
|
|
|
|
|
Execute jobs via SQL server. Read the input sources variables from the
|
|
|
|
table pointed to by I<DBURL>. The I<command> on the command line
|
2016-03-20 22:57:25 +00:00
|
|
|
should be the same as given by B<--sqlmaster>.
|
2016-01-01 14:12:43 +00:00
|
|
|
|
2016-12-14 02:53:33 +00:00
|
|
|
If you have more than one B<--sqlworker> jobs may be run more than
|
|
|
|
once.
|
|
|
|
|
2016-01-01 14:12:43 +00:00
|
|
|
|
2015-07-29 00:19:51 +00:00
|
|
|
=item B<--ssh> I<sshcommand>
|
2015-05-10 20:52:47 +00:00
|
|
|
|
|
|
|
GNU B<parallel> defaults to using B<ssh> for remote access. This can
|
|
|
|
be overridden with B<--ssh>. It can also be set on a per server
|
|
|
|
basis (see B<--sshlogin>).
|
|
|
|
|
|
|
|
|
2013-06-22 12:50:48 +00:00
|
|
|
=item B<--sshdelay> I<secs>
|
2013-01-21 22:09:47 +00:00
|
|
|
|
|
|
|
Delay starting next ssh by I<secs> seconds. GNU B<parallel> will pause
|
|
|
|
I<secs> seconds after starting each ssh. I<secs> can be less than 1
|
|
|
|
seconds.
|
|
|
|
|
|
|
|
|
2017-01-27 22:15:25 +00:00
|
|
|
=item B<-S> I<[@hostgroups/][ncores/]sshlogin[,[@hostgroups/][ncores/]sshlogin[,...]]>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<-S> I<@hostgroup>
|
2015-04-17 21:51:45 +00:00
|
|
|
|
2017-01-27 22:15:25 +00:00
|
|
|
=item B<--sshlogin> I<[@hostgroups/][ncores/]sshlogin[,[@hostgroups/][ncores/]sshlogin[,...]]>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-11-29 23:47:21 +00:00
|
|
|
=item B<--sshlogin> I<@hostgroup>
|
2015-04-17 21:51:45 +00:00
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
Distribute jobs to remote computers. The jobs will be run on a list of
|
2014-11-11 14:51:19 +00:00
|
|
|
remote computers.
|
|
|
|
|
|
|
|
If I<hostgroups> is given, the I<sshlogin> will be added to that
|
|
|
|
hostgroup. Multiple hostgroups are separated by '+'. The I<sshlogin>
|
|
|
|
will always be added to a hostgroup named the same as I<sshlogin>.
|
|
|
|
|
2015-04-17 21:51:45 +00:00
|
|
|
If only the I<@hostgroup> is given, only the sshlogins in that
|
|
|
|
hostgroup will be used. Multiple I<@hostgroup> can be given.
|
2014-11-13 15:57:41 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
GNU B<parallel> will determine the number of CPU cores on the remote
|
|
|
|
computers and run the number of jobs as specified by B<-j>. If the
|
2017-01-27 22:15:25 +00:00
|
|
|
number I<ncores> is given GNU B<parallel> will use this number for
|
|
|
|
number of CPU cores on the host. Normally I<ncores> will not be
|
|
|
|
needed.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
An I<sshlogin> is of the form:
|
|
|
|
|
2013-10-21 20:31:52 +00:00
|
|
|
[sshcommand [options]] [username@]hostname
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-05-17 00:11:38 +00:00
|
|
|
The sshlogin must not require a password (B<ssh-agent>,
|
|
|
|
B<ssh-copy-id>, and B<sshpass> may help with that).
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
The sshlogin ':' is special, it means 'no ssh' and will therefore run
|
|
|
|
on the local computer.
|
|
|
|
|
|
|
|
The sshlogin '..' is special, it read sshlogins from ~/.parallel/sshloginfile
|
|
|
|
|
2011-06-03 12:53:14 +00:00
|
|
|
The sshlogin '-' is special, too, it read sshlogins from stdin
|
|
|
|
(standard input).
|
2011-05-26 21:19:58 +00:00
|
|
|
|
2015-04-22 16:26:41 +00:00
|
|
|
To specify more sshlogins separate the sshlogins by comma, newline (in
|
|
|
|
the same string), or repeat the options multiple times.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
For examples: see B<--sshloginfile>.
|
|
|
|
|
|
|
|
The remote host must have GNU B<parallel> installed.
|
|
|
|
|
|
|
|
B<--sshlogin> is known to cause problems with B<-m> and B<-X>.
|
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
B<--sshlogin> is often used with B<--transferfile>, B<--return>,
|
2011-01-22 22:40:15 +00:00
|
|
|
B<--cleanup>, and B<--trc>.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-10-24 09:30:39 +00:00
|
|
|
=item B<--sshloginfile> I<filename>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-10-24 09:30:39 +00:00
|
|
|
=item B<--slf> I<filename>
|
2011-10-17 01:10:32 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
File with sshlogins. The file consists of sshlogins on separate
|
|
|
|
lines. Empty lines and lines starting with '#' are ignored. Example:
|
|
|
|
|
|
|
|
server.example.com
|
|
|
|
username@server2.example.com
|
|
|
|
8/my-8-core-server.example.com
|
|
|
|
2/my_other_username@my-dualcore.example.net
|
|
|
|
# This server has SSH running on port 2222
|
|
|
|
ssh -p 2222 server.example.net
|
|
|
|
4/ssh -p 2222 quadserver.example.net
|
|
|
|
# Use a different ssh program
|
|
|
|
myssh -p 2222 -l myusername hexacpu.example.net
|
|
|
|
# Use a different ssh program with default number of cores
|
2014-11-11 14:51:19 +00:00
|
|
|
//usr/local/bin/myssh -p 2222 -l myusername hexacpu
|
2010-12-06 23:30:08 +00:00
|
|
|
# Use a different ssh program with 6 cores
|
2014-11-11 14:51:19 +00:00
|
|
|
6//usr/local/bin/myssh -p 2222 -l myusername hexacpu
|
2010-12-06 23:30:08 +00:00
|
|
|
# Assume 16 cores on the local computer
|
|
|
|
16/:
|
2014-11-11 14:51:19 +00:00
|
|
|
# Put server1 in hostgroup1
|
|
|
|
@hostgroup1/server1
|
|
|
|
# Put myusername@server2 in hostgroup1+hostgroup2
|
|
|
|
@hostgroup1+hostgroup2/myusername@server2
|
|
|
|
# Force 4 cores and put 'ssh -p 2222 server3' in hostgroup1
|
|
|
|
@hostgroup1/4/ssh -p 2222 server3
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
When using a different ssh program the last argument must be the hostname.
|
|
|
|
|
2011-10-17 01:10:32 +00:00
|
|
|
Multiple B<--sshloginfile> are allowed.
|
|
|
|
|
2013-08-22 15:24:36 +00:00
|
|
|
GNU B<parallel> will first look for the file in current dir; if that
|
|
|
|
fails it look for the file in ~/.parallel.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
The sshloginfile '..' is special, it read sshlogins from
|
|
|
|
~/.parallel/sshloginfile
|
|
|
|
|
2012-01-13 23:57:48 +00:00
|
|
|
The sshloginfile '.' is special, it read sshlogins from
|
|
|
|
/etc/parallel/sshloginfile
|
|
|
|
|
2011-06-03 12:53:14 +00:00
|
|
|
The sshloginfile '-' is special, too, it read sshlogins from stdin
|
|
|
|
(standard input).
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-08-24 15:19:17 +00:00
|
|
|
If the sshloginfile is changed it will be re-read when a job finishes
|
2014-09-07 15:10:44 +00:00
|
|
|
though at most once per second. This makes it possible to add and
|
|
|
|
remove hosts while running.
|
2014-08-24 15:19:17 +00:00
|
|
|
|
2014-08-24 22:44:19 +00:00
|
|
|
This can be used to have a daemon that updates the sshloginfile to
|
|
|
|
only contain servers that are up:
|
|
|
|
|
|
|
|
cp original.slf tmp2.slf
|
|
|
|
while [ 1 ] ; do
|
2014-11-11 14:51:19 +00:00
|
|
|
nice parallel --nonall -j0 -k --slf original.slf \
|
|
|
|
--tag echo | perl 's/\t$//' > tmp.slf
|
2014-08-24 22:44:19 +00:00
|
|
|
if diff tmp.slf tmp2.slf; then
|
|
|
|
mv tmp.slf tmp2.slf
|
|
|
|
fi
|
|
|
|
sleep 10
|
|
|
|
done &
|
|
|
|
parallel --slf tmp2.slf ...
|
|
|
|
|
2011-08-21 23:01:57 +00:00
|
|
|
|
2014-07-14 16:25:45 +00:00
|
|
|
=item B<--slotreplace> I<replace-str>
|
2011-05-26 12:55:15 +00:00
|
|
|
|
2014-05-22 12:53:33 +00:00
|
|
|
Use the replacement string I<replace-str> instead of B<{%}> for
|
|
|
|
job slot number.
|
2011-05-26 12:55:15 +00:00
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--silent>
|
|
|
|
|
|
|
|
Silent. The job to be run will not be printed. This is the default.
|
|
|
|
Can be reversed with B<-v>.
|
|
|
|
|
|
|
|
|
2011-05-05 18:50:53 +00:00
|
|
|
=item B<--tty>
|
2010-12-21 17:08:16 +00:00
|
|
|
|
|
|
|
Open terminal tty. If GNU B<parallel> is used for starting an
|
|
|
|
interactive program then this option may be needed. It will start only
|
|
|
|
one job at a time (i.e. B<-j1>), not buffer the output (i.e. B<-u>),
|
|
|
|
and it will open a tty for the job. When the job is done, the next job
|
|
|
|
will get the tty.
|
|
|
|
|
2016-04-14 21:30:03 +00:00
|
|
|
You can of course override B<-j1> and B<-u>.
|
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
|
2011-12-21 23:17:49 +00:00
|
|
|
=item B<--tag>
|
2011-09-24 00:16:06 +00:00
|
|
|
|
|
|
|
Tag lines with arguments. Each output line will be prepended with the
|
2011-10-10 20:14:55 +00:00
|
|
|
arguments and TAB (\t). When combined with B<--onall> or B<--nonall>
|
|
|
|
the lines will be prepended with the sshlogin instead.
|
|
|
|
|
|
|
|
B<--tag> is ignored when using B<-u>.
|
2011-09-24 00:16:06 +00:00
|
|
|
|
|
|
|
|
2015-04-27 18:56:34 +00:00
|
|
|
=item B<--tagstring> I<str>
|
2012-05-06 10:43:40 +00:00
|
|
|
|
|
|
|
Tag lines with a string. Each output line will be prepended with
|
|
|
|
I<str> and TAB (\t). I<str> can contain replacement strings such as
|
2016-06-22 19:43:05 +00:00
|
|
|
B<{}>.
|
2012-05-06 10:43:40 +00:00
|
|
|
|
|
|
|
B<--tagstring> is ignored when using B<-u>, B<--onall>, and B<--nonall>.
|
|
|
|
|
|
|
|
|
2017-02-05 01:46:29 +00:00
|
|
|
=item B<--tee> (alpha testing)
|
|
|
|
|
2017-02-05 22:53:28 +00:00
|
|
|
Pipe all data to all jobs. Used with B<--pipe>/B<--pipepart> and
|
|
|
|
B<:::>.
|
2017-02-05 01:46:29 +00:00
|
|
|
|
|
|
|
seq 1000 | parallel --pipe --tee -v wc {} ::: -w -l -c
|
|
|
|
|
2017-02-05 22:53:28 +00:00
|
|
|
How many numbers in 1..1000 contain 0..9, and how many bytes do they
|
|
|
|
fill:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
seq 1000 | parallel --pipe --tee --tag \
|
|
|
|
'grep {1} | wc {2}' ::: {0..9} ::: -l -c
|
2017-02-05 22:53:28 +00:00
|
|
|
|
2017-02-07 23:54:45 +00:00
|
|
|
How many words contain a..z and how many bytes do they fill?
|
|
|
|
|
|
|
|
parallel -a /usr/share/dict/words --pipepart --tee --tag \
|
|
|
|
'grep {1} | wc {2}' ::: {a..z} ::: -l -c
|
|
|
|
|
2017-02-05 01:46:29 +00:00
|
|
|
|
2015-07-29 00:19:51 +00:00
|
|
|
=item B<--termseq> I<sequence>
|
2015-06-22 00:30:30 +00:00
|
|
|
|
|
|
|
Termination sequence. When a job is killed due to B<--timeout>,
|
2015-06-22 19:23:26 +00:00
|
|
|
B<--memfree>, B<--halt>, or abnormal termination of GNU B<parallel>,
|
|
|
|
I<sequence> determines how the job is killed. The default is:
|
2015-06-22 00:30:30 +00:00
|
|
|
|
|
|
|
TERM,200,TERM,100,TERM,50,KILL,25
|
|
|
|
|
|
|
|
which sends a TERM signal, waits 200 ms, sends another TERM signal,
|
|
|
|
waits 100 ms, sends another TERM signal, waits 50 ms, sends a KILL
|
2017-03-21 21:20:38 +00:00
|
|
|
signal, waits 25 ms, and exits. GNU B<parallel> detects if a process
|
2015-06-22 00:30:30 +00:00
|
|
|
dies before the waiting time is up.
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--tmpdir> I<dirname>
|
|
|
|
|
|
|
|
Directory for temporary files. GNU B<parallel> normally buffers output
|
|
|
|
into temporary files in /tmp. By setting B<--tmpdir> you can use a
|
|
|
|
different dir for the files. Setting B<--tmpdir> is equivalent to
|
|
|
|
setting $TMPDIR.
|
|
|
|
|
|
|
|
|
2017-03-02 21:40:46 +00:00
|
|
|
=item B<--tmux>
|
2014-07-16 09:07:41 +00:00
|
|
|
|
|
|
|
Use B<tmux> for output. Start a B<tmux> session and run each job in a
|
|
|
|
window in that session. No other output will be produced.
|
|
|
|
|
|
|
|
|
2017-03-02 21:40:46 +00:00
|
|
|
=item B<--tmuxpane>
|
2016-08-21 13:37:59 +00:00
|
|
|
|
|
|
|
Use B<tmux> for output but put output into panes in the first window.
|
|
|
|
Useful if you want to monitor the progress of less than 100 concurrent
|
|
|
|
jobs.
|
|
|
|
|
|
|
|
|
2016-05-22 12:08:47 +00:00
|
|
|
=item B<--timeout> I<secs>
|
2011-08-21 23:01:57 +00:00
|
|
|
|
2016-05-22 12:08:47 +00:00
|
|
|
Time out for command. If the command runs for longer than I<secs>
|
2017-03-21 21:20:38 +00:00
|
|
|
seconds it will get killed as per B<--termseq>.
|
2011-08-21 23:01:57 +00:00
|
|
|
|
2016-05-22 12:08:47 +00:00
|
|
|
If I<secs> is followed by a % then the timeout will dynamically be
|
2013-06-26 14:07:14 +00:00
|
|
|
computed as a percentage of the median average runtime. Only values
|
2013-04-28 22:43:43 +00:00
|
|
|
> 100% will make sense.
|
|
|
|
|
2011-08-21 23:01:57 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item B<--verbose>
|
|
|
|
|
|
|
|
=item B<-t>
|
|
|
|
|
2011-05-26 21:19:58 +00:00
|
|
|
Print the job to be run on stderr (standard error).
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-08-14 18:11:00 +00:00
|
|
|
See also B<-v>, B<-p>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--transfer>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
Transfer files to remote computers. Shorthand for: B<--transferfile {}>.
|
|
|
|
|
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--transferfile> I<filename>
|
2015-12-13 11:20:50 +00:00
|
|
|
|
2016-02-21 22:07:44 +00:00
|
|
|
=item B<--tf> I<filename>
|
2015-12-13 11:20:50 +00:00
|
|
|
|
|
|
|
B<--transferfile> is used with B<--sshlogin> to transfer files to the
|
|
|
|
remote computers. The files will be transferred using B<rsync> and
|
|
|
|
will be put relative to the default work dir. If the path contains /./
|
|
|
|
the remaining path will be relative to the work dir. E.g.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
echo foo/bar.txt | parallel --transferfile {} \
|
|
|
|
--sshlogin server.example.com wc
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
This will transfer the file I<foo/bar.txt> to the computer
|
2010-12-06 23:30:08 +00:00
|
|
|
I<server.example.com> to the file I<$HOME/foo/bar.txt> before running
|
|
|
|
B<wc foo/bar.txt> on I<server.example.com>.
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
echo /tmp/foo/bar.txt | parallel --transferfile {} \
|
|
|
|
--sshlogin server.example.com wc
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-12-22 17:42:33 +00:00
|
|
|
This will transfer the file I</tmp/foo/bar.txt> to the computer
|
2010-12-06 23:30:08 +00:00
|
|
|
I<server.example.com> to the file I</tmp/foo/bar.txt> before running
|
|
|
|
B<wc /tmp/foo/bar.txt> on I<server.example.com>.
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
echo /tmp/./foo/bar.txt | parallel --transferfile {} \
|
|
|
|
--sshlogin server.example.com wc {= s:.*/./:./: =}
|
2015-12-22 17:42:33 +00:00
|
|
|
|
|
|
|
This will transfer the file I</tmp/foo/bar.txt> to the computer
|
|
|
|
I<server.example.com> to the file I<foo/bar.txt> before running
|
2016-03-20 22:57:25 +00:00
|
|
|
B<wc ./foo/bar.txt> on I<server.example.com>.
|
2015-12-22 17:42:33 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
B<--transferfile> is often used with B<--return> and B<--cleanup>. A
|
|
|
|
shorthand for B<--transferfile {}> is B<--transfer>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
B<--transferfile> is ignored when used with B<--sshlogin :> or when
|
|
|
|
not used with B<--sshlogin>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-02-23 21:32:34 +00:00
|
|
|
=item B<--trc> I<filename>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
Transfer, Return, Cleanup. Shorthand for:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
B<--transferfile {}> B<--return> I<filename> B<--cleanup>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--trim> <n|l|r|lr|rl>
|
|
|
|
|
|
|
|
Trim white space in input.
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
=item n
|
|
|
|
|
|
|
|
No trim. Input is not modified. This is the default.
|
|
|
|
|
|
|
|
=item l
|
|
|
|
|
|
|
|
Left trim. Remove white space from start of input. E.g. " a bc " -> "a bc ".
|
|
|
|
|
|
|
|
=item r
|
|
|
|
|
|
|
|
Right trim. Remove white space from end of input. E.g. " a bc " -> " a bc".
|
|
|
|
|
|
|
|
=item lr
|
|
|
|
|
|
|
|
=item rl
|
|
|
|
|
|
|
|
Both trim. Remove white space from both start and end of input. E.g. "
|
|
|
|
a bc " -> "a bc". This is the default if B<--colsep> is used.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
|
|
=item B<--ungroup>
|
|
|
|
|
|
|
|
=item B<-u>
|
|
|
|
|
2012-05-06 10:43:40 +00:00
|
|
|
Ungroup output. Output is printed as soon as possible and by passes
|
2012-05-06 10:54:51 +00:00
|
|
|
GNU B<parallel> internal processing. This may cause output from
|
|
|
|
different commands to be mixed thus should only be used if you do not
|
|
|
|
care about the output. Compare these:
|
2012-05-06 10:43:40 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq 4 | parallel -j0 \
|
|
|
|
'sleep {};echo -n start{};sleep {};echo {}end'
|
|
|
|
seq 4 | parallel -u -j0 \
|
|
|
|
'sleep {};echo -n start{};sleep {};echo {}end'
|
2012-05-06 10:43:40 +00:00
|
|
|
|
2014-09-07 15:10:44 +00:00
|
|
|
It also disables B<--tag>. GNU B<parallel> outputs faster with
|
|
|
|
B<-u>. Compare the speed of these:
|
|
|
|
|
|
|
|
parallel seq ::: 300000000 >/dev/null
|
|
|
|
parallel -u seq ::: 300000000 >/dev/null
|
|
|
|
parallel --line-buffer seq ::: 300000000 >/dev/null
|
|
|
|
|
|
|
|
Can be reversed with B<--group>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-05-22 12:53:33 +00:00
|
|
|
See also: B<--line-buffer> B<--group>
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=item B<--extensionreplace> I<replace-str>
|
|
|
|
|
2011-10-10 20:14:55 +00:00
|
|
|
=item B<--er> I<replace-str>
|
|
|
|
|
2016-06-22 19:43:05 +00:00
|
|
|
Use the replacement string I<replace-str> instead of B<{.}> for input
|
|
|
|
line without extension.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=item B<--use-cpus-instead-of-cores>
|
|
|
|
|
|
|
|
Count the number of physical CPUs instead of CPU cores. When computing
|
|
|
|
how many jobs to run simultaneously relative to the number of CPU cores
|
|
|
|
you can ask GNU B<parallel> to instead look at the number of physical
|
|
|
|
CPUs. This will make sense for computers that have hyperthreading as
|
|
|
|
two jobs running on one CPU with hyperthreading will run slower than
|
|
|
|
two jobs running on two physical CPUs. Some multi-core CPUs can run
|
|
|
|
faster if only one thread is running per physical CPU. Most users will
|
|
|
|
not need this option.
|
|
|
|
|
|
|
|
|
|
|
|
=item B<-v>
|
|
|
|
|
2011-05-26 21:19:58 +00:00
|
|
|
Verbose. Print the job to be run on stdout (standard output). Can be reversed
|
2010-12-15 23:12:02 +00:00
|
|
|
with B<--silent>. See also B<-t>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Use B<-v> B<-v> to print the wrapping ssh command when running remotely.
|
|
|
|
|
|
|
|
|
|
|
|
=item B<--version>
|
|
|
|
|
|
|
|
=item B<-V>
|
|
|
|
|
|
|
|
Print the version GNU B<parallel> and exit.
|
|
|
|
|
|
|
|
|
2016-03-16 23:50:45 +00:00
|
|
|
=item B<--workdir> I<mydir>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-03-16 23:50:45 +00:00
|
|
|
=item B<--wd> I<mydir>
|
2011-10-10 20:14:55 +00:00
|
|
|
|
2015-12-13 11:20:50 +00:00
|
|
|
Files transferred using B<--transferfile> and B<--return> will be
|
|
|
|
relative to I<mydir> on remote computers, and the command will be
|
|
|
|
executed in the dir I<mydir>.
|
2012-02-20 00:48:28 +00:00
|
|
|
|
|
|
|
The special I<mydir> value B<...> will create working dirs under
|
|
|
|
B<~/.parallel/tmp/> on the remote computers. If B<--cleanup> is given
|
|
|
|
these dirs will be removed.
|
|
|
|
|
|
|
|
The special I<mydir> value B<.> uses the current working dir. If the
|
|
|
|
current working dir is beneath your home dir, the value B<.> is
|
|
|
|
treated as the relative path to your home dir. This means that if your
|
|
|
|
home dir is different on remote computers (e.g. if your login is
|
|
|
|
different) the relative path will still be relative to your home dir.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-02-22 14:01:46 +00:00
|
|
|
To see the difference try:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel -S server pwd ::: ""
|
|
|
|
parallel --wd . -S server pwd ::: ""
|
|
|
|
parallel --wd ... -S server pwd ::: ""
|
2013-02-22 14:01:46 +00:00
|
|
|
|
2016-01-06 15:22:30 +00:00
|
|
|
I<mydir> can contain GNU B<parallel>'s replacement strings.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2017-01-21 18:55:14 +00:00
|
|
|
=item B<--wait>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Wait for all commands to complete.
|
|
|
|
|
2016-12-07 13:33:50 +00:00
|
|
|
Used with B<--semaphore> or B<--sqlmaster>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-08-14 18:11:00 +00:00
|
|
|
See also B<man sem>.
|
2011-06-25 07:22:05 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=item B<-X>
|
|
|
|
|
|
|
|
Multiple arguments with context replace. Insert as many arguments as
|
2011-06-27 21:21:26 +00:00
|
|
|
the command line length permits. If multiple jobs are being run in
|
|
|
|
parallel: distribute the arguments evenly among the jobs. Use B<-j1>
|
|
|
|
to avoid this.
|
|
|
|
|
|
|
|
If B<{}> is not used the arguments will be appended to the line. If
|
|
|
|
B<{}> is used as part of a word (like I<pic{}.jpg>) then the whole
|
|
|
|
word will be repeated. If B<{}> is used multiple times each B<{}> will
|
|
|
|
be replaced with the arguments.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Normally B<-X> will do the right thing, whereas B<-m> can give
|
|
|
|
unexpected results if B<{}> is used as part of a word.
|
|
|
|
|
|
|
|
Support for B<-X> with B<--sshlogin> is limited and may fail.
|
|
|
|
|
|
|
|
See also B<-m>.
|
|
|
|
|
|
|
|
|
|
|
|
=item B<--exit>
|
|
|
|
|
|
|
|
=item B<-x>
|
|
|
|
|
|
|
|
Exit if the size (see the B<-s> option) is exceeded.
|
|
|
|
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=head1 EXAMPLE: Working as xargs -n1. Argument appending
|
|
|
|
|
|
|
|
GNU B<parallel> can work similar to B<xargs -n1>.
|
|
|
|
|
|
|
|
To compress all html files using B<gzip> run:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find . -name '*.html' | parallel gzip --best
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
If the file names may contain a newline use B<-0>. Substitute FOO BAR with
|
|
|
|
FUBAR in all files in this dir and subdirs:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find . -type f -print0 | parallel -q0 perl -i -pe 's/FOO BAR/FUBAR/g'
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Note B<-q> is needed because of the space in 'FOO BAR'.
|
|
|
|
|
|
|
|
|
|
|
|
=head1 EXAMPLE: Reading arguments from command line
|
|
|
|
|
|
|
|
GNU B<parallel> can take the arguments from command line instead of
|
|
|
|
stdin (standard input). To compress all html files in the current dir
|
|
|
|
using B<gzip> run:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel gzip --best ::: *.html
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
To convert *.wav to *.mp3 using LAME running one process per CPU core
|
|
|
|
run:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel lame {} -o {.}.mp3 ::: *.wav
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 EXAMPLE: Inserting multiple arguments
|
|
|
|
|
2011-08-02 21:18:28 +00:00
|
|
|
When moving a lot of files like this: B<mv *.log destdir> you will
|
2010-12-06 23:30:08 +00:00
|
|
|
sometimes get the error:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
bash: /bin/mv: Argument list too long
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
because there are too many files. You can instead do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | grep -E '\.log$' | parallel mv {} destdir
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
This will run B<mv> for each file. It can be done faster if B<mv> gets
|
|
|
|
as many arguments that will fit on the line:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | grep -E '\.log$' | parallel -m mv {} destdir
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 EXAMPLE: Context replace
|
|
|
|
|
|
|
|
To remove the files I<pict0000.jpg> .. I<pict9999.jpg> you could do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq -w 0 9999 | parallel rm pict{}.jpg
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
You could also do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq -w 0 9999 | perl -pe 's/(.*)/pict$1.jpg/' | parallel -m rm
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
The first will run B<rm> 10000 times, while the last will only run
|
|
|
|
B<rm> as many times needed to keep the command line length short
|
|
|
|
enough to avoid B<Argument list too long> (it typically runs 1-2 times).
|
|
|
|
|
|
|
|
You could also run:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq -w 0 9999 | parallel -X rm pict{}.jpg
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
This will also only run B<rm> as many times needed to keep the command
|
|
|
|
line length short enough.
|
|
|
|
|
|
|
|
|
|
|
|
=head1 EXAMPLE: Compute intensive jobs and substitution
|
|
|
|
|
|
|
|
If ImageMagick is installed this will generate a thumbnail of a jpg
|
|
|
|
file:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
convert -geometry 120 foo.jpg thumb_foo.jpg
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-03-29 14:22:56 +00:00
|
|
|
This will run with number-of-cpu-cores jobs in parallel for all jpg
|
|
|
|
files in a directory:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls *.jpg | parallel convert -geometry 120 {} thumb_{}
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
To do it recursively use B<find>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find . -name '*.jpg' | parallel convert -geometry 120 {} {}_thumb.jpg
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Notice how the argument has to start with B<{}> as B<{}> will include path
|
|
|
|
(e.g. running B<convert -geometry 120 ./foo/bar.jpg
|
|
|
|
thumb_./foo/bar.jpg> would clearly be wrong). The command will
|
|
|
|
generate files like ./foo/bar.jpg_thumb.jpg.
|
|
|
|
|
|
|
|
Use B<{.}> to avoid the extra .jpg in the file name. This command will
|
|
|
|
make files like ./foo/bar_thumb.jpg:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find . -name '*.jpg' | parallel convert -geometry 120 {} {.}_thumb.jpg
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 EXAMPLE: Substitution and redirection
|
|
|
|
|
|
|
|
This will generate an uncompressed version of .gz-files next to the .gz-file:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel zcat {} ">"{.} ::: *.gz
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Quoting of > is necessary to postpone the redirection. Another
|
|
|
|
solution is to quote the whole command:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel "zcat {} >{.}" ::: *.gz
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2012-05-27 16:14:25 +00:00
|
|
|
Other special shell characters (such as * ; $ > < | >> <<) also need
|
2010-12-06 23:30:08 +00:00
|
|
|
to be put in quotes, as they may otherwise be interpreted by the shell
|
|
|
|
and not given to GNU B<parallel>.
|
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Composed commands
|
|
|
|
|
|
|
|
A job can consist of several commands. This will print the number of
|
|
|
|
files in each directory:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | parallel 'echo -n {}" "; ls {}|wc -l'
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
To put the output in a file called <name>.dir:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | parallel '(echo -n {}" "; ls {}|wc -l) >{}.dir'
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Even small shell scripts can be run by GNU B<parallel>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find . | parallel 'a={}; name=${a##*/};' \
|
|
|
|
'upper=$(echo "$name" | tr "[:lower:]" "[:upper:]");'\
|
|
|
|
'echo "$name - $upper"'
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | parallel 'mv {} "$(echo {} | tr "[:upper:]" "[:lower:]")"'
|
2011-01-11 12:42:14 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
Given a list of URLs, list all URLs that fail to download. Print the
|
|
|
|
line number and the URL.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat urlfile | parallel "wget {} 2>/dev/null || grep -n {} urlfile"
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-03-29 14:22:56 +00:00
|
|
|
Create a mirror directory with the same filenames except all files and
|
|
|
|
symlinks are empty files.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cp -rs /the/source/dir mirror_dir
|
|
|
|
find mirror_dir -type l | parallel -m rm {} '&&' touch {}
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2012-05-27 16:14:25 +00:00
|
|
|
Find the files in a list that do not exist
|
2011-12-18 16:10:26 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat file_list | parallel 'if [ ! -e {} ] ; then echo {}; fi'
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2013-06-30 16:11:36 +00:00
|
|
|
|
2016-02-19 21:15:08 +00:00
|
|
|
=head1 EXAMPLE: Composed command with multiple input sources
|
|
|
|
|
|
|
|
You have a dir with files named as 24 hours in 5 minute intervals:
|
|
|
|
00:00, 00:05, 00:10 .. 23:55. You want to find the files missing:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel [ -f {1}:{2} ] "||" echo {1}:{2} does not exist \
|
|
|
|
::: {00..23} ::: {00..55..5}
|
2016-02-19 21:15:08 +00:00
|
|
|
|
|
|
|
|
2013-06-30 16:11:36 +00:00
|
|
|
=head1 EXAMPLE: Calling Bash functions
|
|
|
|
|
|
|
|
If the composed command is longer than a line, it becomes hard to
|
|
|
|
read. In Bash you can use functions. Just remember to B<export -f> the
|
|
|
|
function.
|
|
|
|
|
|
|
|
doit() {
|
|
|
|
echo Doing it for $1
|
|
|
|
sleep 2
|
|
|
|
echo Done with $1
|
|
|
|
}
|
|
|
|
export -f doit
|
|
|
|
parallel doit ::: 1 2 3
|
|
|
|
|
|
|
|
doubleit() {
|
|
|
|
echo Doing it for $1 $2
|
|
|
|
sleep 2
|
|
|
|
echo Done with $1 $2
|
|
|
|
}
|
|
|
|
export -f doubleit
|
|
|
|
parallel doubleit ::: 1 2 3 ::: a b
|
|
|
|
|
2013-12-02 20:28:48 +00:00
|
|
|
To do this on remote servers you need to transfer the function using
|
|
|
|
B<--env>:
|
|
|
|
|
|
|
|
parallel --env doit -S server doit ::: 1 2 3
|
|
|
|
parallel --env doubleit -S server doubleit ::: 1 2 3 ::: a b
|
2013-06-30 16:11:36 +00:00
|
|
|
|
2014-09-07 15:10:44 +00:00
|
|
|
If your environment (aliases, variables, and functions) is small you
|
|
|
|
can copy the full environment without having to B<export -f>
|
2016-08-03 21:42:15 +00:00
|
|
|
anything. See B<env_parallel>.
|
2014-09-07 15:10:44 +00:00
|
|
|
|
2013-06-30 16:11:36 +00:00
|
|
|
|
2014-10-09 20:21:28 +00:00
|
|
|
=head1 EXAMPLE: Function tester
|
|
|
|
|
|
|
|
To test a program with different parameters:
|
|
|
|
|
|
|
|
tester() {
|
|
|
|
if (eval "$@") >&/dev/null; then
|
|
|
|
perl -e 'printf "\033[30;102m[ OK ]\033[0m @ARGV\n"' "$@"
|
|
|
|
else
|
|
|
|
perl -e 'printf "\033[30;101m[FAIL]\033[0m @ARGV\n"' "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
export -f tester
|
|
|
|
parallel tester my_program ::: arg1 arg2
|
|
|
|
parallel tester exit ::: 1 0 2 0
|
|
|
|
|
|
|
|
If B<my_program> fails a red FAIL will be printed followed by the failing
|
|
|
|
command; otherwise a green OK will be printed followed by the command.
|
|
|
|
|
|
|
|
|
2015-06-21 08:39:48 +00:00
|
|
|
=head1 EXAMPLE: Log rotate
|
|
|
|
|
|
|
|
Log rotation renames a logfile to an extension with a higher number:
|
|
|
|
log.1 becomes log.2, log.2 becomes log.3, and so on. The oldest log is
|
|
|
|
removed. To avoid overwriting files the process starts backwards from
|
|
|
|
the high number to the low number. This will keep 10 old versions of
|
|
|
|
the log:
|
|
|
|
|
|
|
|
seq 9 -1 1 | parallel -j1 mv log.{} log.'{= $_++ =}'
|
|
|
|
mv log log.1
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Removing file extension when processing files
|
|
|
|
|
|
|
|
When processing files removing the file extension using B<{.}> is
|
|
|
|
often useful.
|
|
|
|
|
|
|
|
Create a directory for each zip-file and unzip it in that dir:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel 'mkdir {.}; cd {.}; unzip ../{}' ::: *.zip
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Recompress all .gz files in current directory using B<bzip2> running 1
|
|
|
|
job per CPU core in parallel:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel "zcat {} | bzip2 >{.}.bz2 && rm {}" ::: *.gz
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Convert all WAV files to MP3 using LAME:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find sounddir -type f -name '*.wav' | parallel lame {} -o {.}.mp3
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Put all converted in the same directory:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find sounddir -type f -name '*.wav' | \
|
|
|
|
parallel lame {} -o mydir/{/.}.mp3
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2014-09-07 15:10:44 +00:00
|
|
|
=head1 EXAMPLE: Removing two file extensions when processing files
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
If you have directory with tar.gz files and want these extracted in
|
|
|
|
the corresponding dir (e.g foo.tar.gz will be extracted in the dir
|
|
|
|
foo) you can do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --plus 'mkdir {..}; tar -C {..} -xf {}' ::: *.tar.gz
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2016-08-03 21:42:15 +00:00
|
|
|
=head1 EXAMPLE: Download 24 images for each of the past 30 days
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Let us assume a website stores images like:
|
|
|
|
|
2013-06-30 16:11:36 +00:00
|
|
|
http://www.example.com/path/to/YYYYMMDD_##.jpg
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-08-03 21:42:15 +00:00
|
|
|
where YYYYMMDD is the date and ## is the number 01-24. This will
|
2011-05-26 11:14:03 +00:00
|
|
|
download images for the past 30 days:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
getit() {
|
|
|
|
date=$(date -d "today -$1 days" +%Y%m%d)
|
|
|
|
num=$2
|
|
|
|
echo wget http://www.example.com/path/to/${date}_${num}.jpg
|
|
|
|
}
|
|
|
|
export -f getit
|
|
|
|
|
|
|
|
parallel getit ::: $(seq 30) ::: $(seq -w 24)
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
B<$(date -d "today -$1 days" +%Y%m%d)> will give the dates in
|
|
|
|
YYYYMMDD with B<$1> days subtracted.
|
2011-05-26 21:19:58 +00:00
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2014-10-07 22:27:13 +00:00
|
|
|
=head1 EXAMPLE: Copy files as last modified date (ISO8601) with added random digits
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
find . | parallel cp {} '../destdir/{= $a=int(10000*rand); $_=pQ($_);
|
|
|
|
$_=`date -r "$_" +%FT%T"$a"`; chomp; =}'
|
2014-11-11 14:51:19 +00:00
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
B<{=> and B<=}> mark a perl expression. B<pQ> quotes the
|
|
|
|
string. B<date +%FT%T> is the date in ISO8601 with time.
|
2014-10-07 22:27:13 +00:00
|
|
|
|
|
|
|
|
2014-07-14 16:25:45 +00:00
|
|
|
=head1 EXAMPLE: Digtal clock with "blinking" :
|
|
|
|
|
|
|
|
The : in a digital clock blinks. To make every other line have a ':'
|
|
|
|
and the rest a ' ' a perl expression is used to look at the 3rd input
|
|
|
|
source. If the value modudo 2 is 1: Use ":" otherwise use " ":
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel -k echo {1}'{=3 $_=$_%2?":":" "=}'{2}{3} \
|
|
|
|
::: {0..12} ::: {0..5} ::: {0..9}
|
2014-07-14 16:25:45 +00:00
|
|
|
|
2014-10-07 22:27:13 +00:00
|
|
|
|
2014-09-07 15:10:44 +00:00
|
|
|
=head1 EXAMPLE: Aggregating content of files
|
|
|
|
|
|
|
|
This:
|
|
|
|
|
|
|
|
parallel --header : echo x{X}y{Y}z{Z} \> x{X}y{Y}z{Z} \
|
|
|
|
::: X {1..5} ::: Y {01..10} ::: Z {1..5}
|
|
|
|
|
|
|
|
will generate the files x1y01z1 .. x5y10z5. If you want to aggregate
|
|
|
|
the output grouping on x and z you can do this:
|
|
|
|
|
|
|
|
parallel eval 'cat {=s/y01/y*/=} > {=s/y01//=}' ::: *y01*
|
|
|
|
|
|
|
|
For all values of x and z it runs commands like:
|
|
|
|
|
|
|
|
cat x1y*z1 > x1z1
|
|
|
|
|
2015-08-30 23:57:14 +00:00
|
|
|
So you end up with x1z1 .. x5z5 each containing the content of all
|
2014-09-07 15:10:44 +00:00
|
|
|
values of y.
|
|
|
|
|
2014-07-14 16:25:45 +00:00
|
|
|
|
2011-10-10 20:14:55 +00:00
|
|
|
=head1 EXAMPLE: Breadth first parallel web crawler/mirrorer
|
2011-07-27 17:34:30 +00:00
|
|
|
|
2011-10-10 20:14:55 +00:00
|
|
|
This script below will crawl and mirror a URL in parallel. It
|
|
|
|
downloads first pages that are 1 click down, then 2 clicks down, then
|
|
|
|
3; instead of the normal depth first, where the first link link on
|
|
|
|
each page is fetched first.
|
|
|
|
|
|
|
|
Run like this:
|
2011-07-27 17:34:30 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
PARALLEL=-j100 ./parallel-crawl http://gatt.org.yeslab.org/
|
2011-07-28 18:12:02 +00:00
|
|
|
|
|
|
|
Remove the B<wget> part if you only want a web crawler.
|
|
|
|
|
|
|
|
It works by fetching a page from a list of URLs and looking for links
|
|
|
|
in that page that are within the same starting URL and that have not
|
|
|
|
already been seen. These links are added to a new queue. When all the
|
|
|
|
pages from the list is done, the new queue is moved to the list of
|
|
|
|
URLs and the process is started over until no unseen links are found.
|
2011-07-27 17:34:30 +00:00
|
|
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
2011-07-28 18:12:02 +00:00
|
|
|
# E.g. http://gatt.org.yeslab.org/
|
2011-07-27 17:34:30 +00:00
|
|
|
URL=$1
|
2011-07-28 18:12:02 +00:00
|
|
|
# Stay inside the start dir
|
|
|
|
BASEURL=$(echo $URL | perl -pe 's:#.*::; s:(//.*/)[^/]*:$1:')
|
2011-07-27 17:34:30 +00:00
|
|
|
URLLIST=$(mktemp urllist.XXXX)
|
|
|
|
URLLIST2=$(mktemp urllist.XXXX)
|
|
|
|
SEEN=$(mktemp seen.XXXX)
|
|
|
|
|
|
|
|
# Spider to get the URLs
|
|
|
|
echo $URL >$URLLIST
|
|
|
|
cp $URLLIST $SEEN
|
|
|
|
|
|
|
|
while [ -s $URLLIST ] ; do
|
|
|
|
cat $URLLIST |
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel lynx -listonly -image_links -dump {} \; \
|
|
|
|
wget -qm -l1 -Q1 {} \; echo Spidered: {} \>\&2 |
|
2017-03-21 21:20:38 +00:00
|
|
|
perl -ne 's/#.*//; s/\s+\d+.\s(\S+)$/$1/ and
|
|
|
|
do { $seen{$1}++ or print }' |
|
2011-07-28 18:12:02 +00:00
|
|
|
grep -F $BASEURL |
|
2011-07-27 17:34:30 +00:00
|
|
|
grep -v -x -F -f $SEEN | tee -a $SEEN > $URLLIST2
|
|
|
|
mv $URLLIST2 $URLLIST
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -f $URLLIST $URLLIST2 $SEEN
|
|
|
|
|
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
=head1 EXAMPLE: Process files from a tar file while unpacking
|
|
|
|
|
|
|
|
If the files to be processed are in a tar file then unpacking one file
|
|
|
|
and processing it immediately may be faster than first unpacking all
|
|
|
|
files.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
tar xvf foo.tgz | perl -ne 'print $l;$l=$_;END{print $l}' | \
|
|
|
|
parallel echo
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2016-01-01 14:12:43 +00:00
|
|
|
The Perl one-liner is needed to make sure the file is complete before
|
|
|
|
handing it to GNU B<parallel>.
|
2011-04-07 19:54:02 +00:00
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Rewriting a for-loop and a while-read-loop
|
|
|
|
|
|
|
|
for-loops like this:
|
|
|
|
|
|
|
|
(for x in `cat list` ; do
|
|
|
|
do_something $x
|
|
|
|
done) | process_output
|
|
|
|
|
|
|
|
and while-read-loops like this:
|
|
|
|
|
|
|
|
cat list | (while read x ; do
|
|
|
|
do_something $x
|
|
|
|
done) | process_output
|
|
|
|
|
|
|
|
can be written like this:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat list | parallel do_something | process_output
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2012-12-10 18:12:35 +00:00
|
|
|
For example: Find which host name in a list has IP address 1.2.3 4:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat hosts.txt | parallel -P 100 host | grep 1.2.3.4
|
2012-12-10 18:12:35 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
If the processing requires more steps the for-loop like this:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
(for x in `cat list` ; do
|
|
|
|
no_extension=${x%.*};
|
2017-03-21 21:20:38 +00:00
|
|
|
do_step1 $x scale $no_extension.jpg
|
2014-11-11 14:51:19 +00:00
|
|
|
do_step2 <$x $no_extension
|
|
|
|
done) | process_output
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
and while-loops like this:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat list | (while read x ; do
|
|
|
|
no_extension=${x%.*};
|
2017-03-21 21:20:38 +00:00
|
|
|
do_step1 $x scale $no_extension.jpg
|
2014-11-11 14:51:19 +00:00
|
|
|
do_step2 <$x $no_extension
|
|
|
|
done) | process_output
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
can be written like this:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
cat list | parallel "do_step1 {} scale {.}.jpg ; do_step2 <{} {.}" |\
|
2014-11-11 14:51:19 +00:00
|
|
|
process_output
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-22 20:31:34 +00:00
|
|
|
If the body of the loop is bigger, it improves readability to use a function:
|
|
|
|
|
|
|
|
(for x in `cat list` ; do
|
|
|
|
do_something $x
|
|
|
|
[... 100 lines that do something with $x ...]
|
|
|
|
done) | process_output
|
|
|
|
|
|
|
|
cat list | (while read x ; do
|
|
|
|
do_something $x
|
|
|
|
[... 100 lines that do something with $x ...]
|
|
|
|
done) | process_output
|
|
|
|
|
|
|
|
can both be rewritten as:
|
|
|
|
|
|
|
|
doit() {
|
|
|
|
x=$1
|
|
|
|
do_something $x
|
|
|
|
[... 100 lines that do something with $x ...]
|
|
|
|
}
|
|
|
|
export -f doit
|
|
|
|
cat list | parallel doit
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-03 22:30:56 +00:00
|
|
|
=head1 EXAMPLE: Rewriting nested for-loops
|
|
|
|
|
|
|
|
Nested for-loops like this:
|
|
|
|
|
|
|
|
(for x in `cat xlist` ; do
|
|
|
|
for y in `cat ylist` ; do
|
|
|
|
do_something $x $y
|
|
|
|
done
|
|
|
|
done) | process_output
|
|
|
|
|
|
|
|
can be written like this:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel do_something {1} {2} :::: xlist ylist | process_output
|
2011-05-03 22:30:56 +00:00
|
|
|
|
2011-08-09 20:00:31 +00:00
|
|
|
Nested for-loops like this:
|
|
|
|
|
2015-07-01 02:46:32 +00:00
|
|
|
(for colour in red green blue ; do
|
2011-08-09 20:00:31 +00:00
|
|
|
for size in S M L XL XXL ; do
|
2015-07-01 02:46:32 +00:00
|
|
|
echo $colour $size
|
2011-08-09 20:00:31 +00:00
|
|
|
done
|
|
|
|
done) | sort
|
|
|
|
|
|
|
|
can be written like this:
|
|
|
|
|
2015-07-01 02:46:32 +00:00
|
|
|
parallel echo {1} {2} ::: red green blue ::: S M L XL XXL | sort
|
2011-08-09 20:00:31 +00:00
|
|
|
|
2011-05-03 22:30:56 +00:00
|
|
|
|
2013-08-27 09:04:14 +00:00
|
|
|
=head1 EXAMPLE: Finding the lowest difference between files
|
|
|
|
|
|
|
|
B<diff> is good for finding differences in text files. B<diff | wc -l>
|
|
|
|
gives an indication of the size of the difference. To find the
|
|
|
|
differences between all files in the current dir do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --tag 'diff {1} {2} | wc -l' ::: * ::: * | sort -nk3
|
2013-08-27 09:04:14 +00:00
|
|
|
|
|
|
|
This way it is possible to see if some files are closer to other
|
|
|
|
files.
|
|
|
|
|
|
|
|
|
2012-01-22 03:42:05 +00:00
|
|
|
=head1 EXAMPLE: for-loops with column names
|
|
|
|
|
|
|
|
When doing multiple nested for-loops it can be easier to keep track of
|
|
|
|
the loop variable if is is named instead of just having a number. Use
|
|
|
|
B<--header :> to let the first argument be an named alias for the
|
|
|
|
positional replacement string:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --header : echo {colour} {size} \
|
|
|
|
::: colour red green blue ::: size S M L XL XXL
|
2012-01-22 03:42:05 +00:00
|
|
|
|
|
|
|
This also works if the input file is a file with columns:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat addressbook.tsv | \
|
|
|
|
parallel --colsep '\t' --header : echo {Name} {E-mail address}
|
2012-01-22 03:42:05 +00:00
|
|
|
|
|
|
|
|
2012-10-15 23:24:35 +00:00
|
|
|
=head1 EXAMPLE: Count the differences between all files in a dir
|
|
|
|
|
|
|
|
Using B<--results> the results are saved in /tmp/diffcount*.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --results /tmp/diffcount "diff -U 0 {1} {2} | \
|
|
|
|
tail -n +3 |grep -v '^@'|wc -l" ::: * ::: *
|
2012-10-15 23:24:35 +00:00
|
|
|
|
|
|
|
To see the difference between file A and file B look at the file
|
2014-09-07 15:10:44 +00:00
|
|
|
'/tmp/diffcount/1/A/2/B'.
|
2012-10-15 23:24:35 +00:00
|
|
|
|
|
|
|
|
2012-09-27 09:41:40 +00:00
|
|
|
=head1 EXAMPLE: Speeding up fast jobs
|
|
|
|
|
2014-08-27 21:29:15 +00:00
|
|
|
Starting a job on the local machine takes around 10 ms. This can be a
|
2012-09-27 09:41:40 +00:00
|
|
|
big overhead if the job takes very few ms to run. Often you can group
|
|
|
|
small jobs together using B<-X> which will make the overhead less
|
|
|
|
significant. Compare the speed of these:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq -w 0 9999 | parallel touch pict{}.jpg
|
|
|
|
seq -w 0 9999 | parallel -X touch pict{}.jpg
|
2012-09-27 09:41:40 +00:00
|
|
|
|
|
|
|
If your program cannot take multiple arguments, then you can use GNU
|
|
|
|
B<parallel> to spawn multiple GNU B<parallel>s:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq -w 0 999999 | parallel -j10 --pipe parallel -j0 touch pict{}.jpg
|
2012-09-27 09:41:40 +00:00
|
|
|
|
2014-08-27 21:29:15 +00:00
|
|
|
If B<-j0> normally spawns 252 jobs, then the above will try to spawn
|
|
|
|
2520 jobs. On a normal GNU/Linux system you can spawn 32000 jobs using
|
2014-08-29 21:33:57 +00:00
|
|
|
this technique with no problems. To raise the 32000 jobs limit raise
|
|
|
|
/proc/sys/kernel/pid_max to 4194303.
|
2012-09-27 09:41:40 +00:00
|
|
|
|
|
|
|
|
2012-01-22 03:42:05 +00:00
|
|
|
=head1 EXAMPLE: Using shell variables
|
|
|
|
|
|
|
|
When using shell variables you need to quote them correctly as they
|
|
|
|
may otherwise be split on spaces.
|
|
|
|
|
|
|
|
Notice the difference between:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
V=("My brother's 12\" records are worth <\$\$\$>"'!' Foo Bar)
|
|
|
|
parallel echo ::: ${V[@]} # This is probably not what you want
|
2012-01-22 03:42:05 +00:00
|
|
|
|
|
|
|
and:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
V=("My brother's 12\" records are worth <\$\$\$>"'!' Foo Bar)
|
|
|
|
parallel echo ::: "${V[@]}"
|
2012-01-22 03:42:05 +00:00
|
|
|
|
|
|
|
When using variables in the actual command that contains special
|
|
|
|
characters (e.g. space) you can quote them using B<'"$VAR"'> or using
|
|
|
|
"'s and B<-q>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
V="Here are two "
|
|
|
|
parallel echo "'$V'" ::: spaces
|
|
|
|
parallel -q echo "$V" ::: spaces
|
2012-01-22 03:42:05 +00:00
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Group output lines
|
|
|
|
|
|
|
|
When running jobs that output data, you often do not want the output
|
2014-06-23 00:10:53 +00:00
|
|
|
of multiple jobs to run together. GNU B<parallel> defaults to grouping
|
|
|
|
the output of each job, so the output is printed when the job
|
|
|
|
finishes. If you want full lines to be printed while the job is
|
|
|
|
running you can use B<--line-buffer>. If you want output to be
|
|
|
|
printed as soon as possible you can use B<-u>.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Compare the output of:
|
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
parallel traceroute ::: qubes-os.org debian.org freenetproject.org
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --line-buffer traceroute ::: \
|
|
|
|
qubes-os.org debian.org freenetproject.org
|
2016-03-26 09:35:13 +00:00
|
|
|
parallel -u traceroute ::: qubes-os.org debian.org freenetproject.org
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2011-10-10 20:14:55 +00:00
|
|
|
=head1 EXAMPLE: Tag output lines
|
|
|
|
|
|
|
|
GNU B<parallel> groups the output lines, but it can be hard to see
|
|
|
|
where the different jobs begin. B<--tag> prepends the argument to make
|
|
|
|
that more visible:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --tag traceroute ::: \
|
|
|
|
qubes-os.org debian.org freenetproject.org
|
2011-10-10 20:14:55 +00:00
|
|
|
|
2014-06-23 00:10:53 +00:00
|
|
|
B<--tag> works with B<--line-buffer> but not with B<-u>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --tag --line-buffer traceroute \
|
2016-03-26 09:35:13 +00:00
|
|
|
::: qubes-os.org debian.org freenetproject.org
|
2014-06-23 00:10:53 +00:00
|
|
|
|
2011-10-10 20:20:18 +00:00
|
|
|
Check the uptime of the servers in I<~/.parallel/sshloginfile>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --tag -S .. --nonall uptime
|
2011-10-10 20:20:18 +00:00
|
|
|
|
2011-10-10 20:14:55 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Keep order of output same as order of input
|
|
|
|
|
|
|
|
Normally the output of a job will be printed as soon as it
|
|
|
|
completes. Sometimes you want the order of the output to remain the
|
|
|
|
same as the order of the input. This is often important, if the output
|
|
|
|
is used as input for another system. B<-k> will make sure the order of
|
|
|
|
output will be in the same order as input even if later jobs end
|
|
|
|
before earlier jobs.
|
|
|
|
|
|
|
|
Append a string to every line in a text file:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat textfile | parallel -k echo {} append_string
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
If you remove B<-k> some of the lines may come out in the wrong order.
|
|
|
|
|
|
|
|
Another example is B<traceroute>:
|
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
parallel traceroute ::: qubes-os.org debian.org freenetproject.org
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
will give traceroute of qubes-os.org, debian.org and
|
2010-12-06 23:30:08 +00:00
|
|
|
freenetproject.org, but it will be sorted according to which job
|
|
|
|
completed first.
|
|
|
|
|
|
|
|
To keep the order the same as input run:
|
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
parallel -k traceroute ::: qubes-os.org debian.org freenetproject.org
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
This will make sure the traceroute to qubes-os.org will be printed
|
2010-12-06 23:30:08 +00:00
|
|
|
first.
|
|
|
|
|
|
|
|
A bit more complex example is downloading a huge file in chunks in
|
|
|
|
parallel: Some internet connections will deliver more data if you
|
|
|
|
download files in parallel. For downloading files in parallel see:
|
|
|
|
"EXAMPLE: Download 10 images for each of the past 30 days". But if you
|
|
|
|
are downloading a big file you can download the file in chunks in
|
|
|
|
parallel.
|
|
|
|
|
|
|
|
To download byte 10000000-19999999 you can use B<curl>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
curl -r 10000000-19999999 http://example.com/the/big/file >file.part
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
To download a 1 GB file we need 100 10MB chunks downloaded and
|
|
|
|
combined in the correct order.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq 0 99 | parallel -k curl -r \
|
|
|
|
{}0000000-{}9999999 http://example.com/the/big/file > file
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Parallel grep
|
|
|
|
|
|
|
|
B<grep -r> greps recursively through directories. On multicore CPUs
|
|
|
|
GNU B<parallel> can often speed this up.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find . -type f | parallel -k -j150% -n 1000 -m grep -H -n STRING {}
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
This will run 1.5 job per core, and give 1000 arguments to B<grep>.
|
|
|
|
|
|
|
|
|
2014-07-15 00:40:38 +00:00
|
|
|
=head1 EXAMPLE: Grepping n lines for m regular expressions.
|
|
|
|
|
|
|
|
The simplest solution to grep a big file for a lot of regexps is:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
grep -f regexps.txt bigfile
|
2014-07-15 00:40:38 +00:00
|
|
|
|
|
|
|
Or if the regexps are fixed strings:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
grep -F -f regexps.txt bigfile
|
2014-07-15 00:40:38 +00:00
|
|
|
|
2016-07-06 13:58:47 +00:00
|
|
|
There are 3 limiting factors: CPU, RAM, and disk I/O.
|
2014-07-15 00:40:38 +00:00
|
|
|
|
2016-07-06 13:58:47 +00:00
|
|
|
RAM is easy to measure: If the B<grep> process takes up most of your
|
|
|
|
free memory (e.g. when running B<top>), then RAM is a limiting factor.
|
2014-07-15 00:40:38 +00:00
|
|
|
|
2016-07-06 13:58:47 +00:00
|
|
|
CPU is also easy to measure: If the B<grep> takes >90% CPU in B<top>,
|
|
|
|
then the CPU is a limiting factor, and parallelization will speed this
|
|
|
|
up.
|
2014-07-15 00:40:38 +00:00
|
|
|
|
2016-07-06 13:58:47 +00:00
|
|
|
It is harder to see if disk I/O is the limiting factor, and depending
|
|
|
|
on the disk system it may be faster or slower to parallelize. The only
|
|
|
|
way to know for certain is to test and measure.
|
|
|
|
|
|
|
|
|
|
|
|
=head2 Limiting factor: RAM
|
|
|
|
|
|
|
|
The normal B<grep -f regexs.txt bigfile> works no matter the size of
|
|
|
|
bigfile, but if regexps.txt is so big it cannot fit into memory, then
|
|
|
|
you need to split this.
|
|
|
|
|
|
|
|
B<grep -F> takes around 100 bytes of RAM and B<grep> takes about 500
|
|
|
|
bytes of RAM per 1 byte of regexp. So if regexps.txt is 1% of your
|
|
|
|
RAM, then it may be too big.
|
|
|
|
|
|
|
|
If you can convert your regexps into fixed strings do that. E.g. if
|
|
|
|
the lines you are looking for in bigfile all looks like:
|
|
|
|
|
|
|
|
ID1 foo bar baz Identifier1 quux
|
|
|
|
fubar ID2 foo bar baz Identifier2
|
|
|
|
|
|
|
|
then your regexps.txt can be converted from:
|
|
|
|
|
|
|
|
ID1.*Identifier1
|
|
|
|
ID2.*Identifier2
|
|
|
|
|
|
|
|
into:
|
|
|
|
|
|
|
|
ID1 foo bar baz Identifier1
|
|
|
|
ID2 foo bar baz Identifier2
|
|
|
|
|
|
|
|
This way you can use B<grep -F> which takes around 80% less memory and
|
|
|
|
is much faster.
|
|
|
|
|
|
|
|
If it still does not fit in memory you can do this:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --pipepart -a regexps.txt --block 1M grep -Ff - -n bigfile |
|
2016-07-06 13:58:47 +00:00
|
|
|
sort -un | perl -pe 's/^\d+://'
|
|
|
|
|
|
|
|
The 1M should be your free memory divided by the number of cores and
|
|
|
|
divided by 200 for B<grep -F> and by 1000 for normal B<grep>. On
|
|
|
|
GNU/Linux you can do:
|
|
|
|
|
|
|
|
free=$(awk '/^((Swap)?Cached|MemFree|Buffers):/ { sum += $2 }
|
|
|
|
END { print sum }' /proc/meminfo)
|
|
|
|
percpu=$((free / 200 / $(parallel --number-of-cores)))k
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --pipepart -a regexps.txt --block $percpu --compress \
|
|
|
|
grep -F -f - -n bigfile |
|
2016-07-06 13:58:47 +00:00
|
|
|
sort -un | perl -pe 's/^\d+://'
|
|
|
|
|
|
|
|
If you can live with duplicated lines and wrong order, it is faster to do:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --pipepart -a regexps.txt --block $percpu --compress \
|
|
|
|
grep -F -f - bigfile
|
2016-07-06 13:58:47 +00:00
|
|
|
|
|
|
|
=head2 Limiting factor: CPU
|
|
|
|
|
|
|
|
If the CPU is the limiting factor parallelization should be done on
|
|
|
|
the regexps:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
cat regexp.txt | parallel --pipe -L1000 --round-robin --compress \
|
|
|
|
grep -f - -n bigfile |
|
2016-07-06 13:58:47 +00:00
|
|
|
sort -un | perl -pe 's/^\d+://'
|
|
|
|
|
|
|
|
The command will start one B<grep> per CPU and read I<bigfile> one
|
|
|
|
time per CPU, but as that is done in parallel, all reads except the
|
|
|
|
first will be cached in RAM. Depending on the size of I<regexp.txt> it
|
|
|
|
may be faster to use B<--block 10m> instead of B<-L1000>.
|
2014-07-15 00:40:38 +00:00
|
|
|
|
|
|
|
Some storage systems perform better when reading multiple chunks in
|
|
|
|
parallel. This is true for some RAID systems and for some network file
|
2016-05-25 22:13:48 +00:00
|
|
|
systems. To parallelize the reading of I<bigfile>:
|
2014-07-15 00:40:38 +00:00
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel --pipepart --block 100M -a bigfile -k --compress \
|
|
|
|
grep -f regexp.txt
|
2014-07-15 00:40:38 +00:00
|
|
|
|
2016-05-25 22:13:48 +00:00
|
|
|
This will split I<bigfile> into 100MB chunks and run B<grep> on each of
|
|
|
|
these chunks. To parallelize both reading of I<bigfile> and I<regexp.txt>
|
|
|
|
combine the two using B<--fifo>:
|
2014-07-15 00:40:38 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --pipepart --block 100M -a bigfile --fifo cat regexp.txt \
|
2014-07-15 00:40:38 +00:00
|
|
|
\| parallel --pipe -L1000 --round-robin grep -f - {}
|
|
|
|
|
2014-10-07 22:27:13 +00:00
|
|
|
If a line matches multiple regexps, the line may be duplicated.
|
|
|
|
|
2016-07-06 13:58:47 +00:00
|
|
|
=head2 Bigger problem
|
|
|
|
|
|
|
|
If the problem is too big to be solved by this, you are probably ready
|
|
|
|
for Lucene.
|
|
|
|
|
2014-07-15 00:40:38 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Using remote computers
|
|
|
|
|
|
|
|
To run commands on a remote computer SSH needs to be set up and you
|
2011-05-03 22:30:56 +00:00
|
|
|
must be able to login without entering a password (The commands
|
2016-05-17 00:11:38 +00:00
|
|
|
B<ssh-copy-id>, B<ssh-agent>, and B<sshpass> may help you do that).
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-10-21 20:31:52 +00:00
|
|
|
If you need to login to a whole cluster, you typically do not want to
|
|
|
|
accept the host key for every host. You want to accept them the first
|
|
|
|
time and be warned if they are ever changed. To do that:
|
|
|
|
|
|
|
|
# Add the servers to the sshloginfile
|
|
|
|
(echo servera; echo serverb) > .parallel/my_cluster
|
|
|
|
# Make sure .ssh/config exist
|
|
|
|
touch .ssh/config
|
|
|
|
cp .ssh/config .ssh/config.backup
|
|
|
|
# Disable StrictHostKeyChecking temporarily
|
|
|
|
(echo 'Host *'; echo StrictHostKeyChecking no) >> .ssh/config
|
|
|
|
parallel --slf my_cluster --nonall true
|
|
|
|
# Remove the disabling of StrictHostKeyChecking
|
2014-07-27 22:30:54 +00:00
|
|
|
mv .ssh/config.backup .ssh/config
|
2013-10-21 20:31:52 +00:00
|
|
|
|
|
|
|
The servers in B<.parallel/my_cluster> are now added in B<.ssh/known_hosts>.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
To run B<echo> on B<server.example.com>:
|
|
|
|
|
2011-03-09 15:23:53 +00:00
|
|
|
seq 10 | parallel --sshlogin server.example.com echo
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
To run commands on more than one remote computer run:
|
|
|
|
|
2011-03-09 15:23:53 +00:00
|
|
|
seq 10 | parallel --sshlogin server.example.com,server2.example.net echo
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Or:
|
|
|
|
|
2011-03-09 15:23:53 +00:00
|
|
|
seq 10 | parallel --sshlogin server.example.com \
|
2010-12-06 23:30:08 +00:00
|
|
|
--sshlogin server2.example.net echo
|
|
|
|
|
|
|
|
If the login username is I<foo> on I<server2.example.net> use:
|
|
|
|
|
2011-03-09 15:23:53 +00:00
|
|
|
seq 10 | parallel --sshlogin server.example.com \
|
2010-12-06 23:30:08 +00:00
|
|
|
--sshlogin foo@server2.example.net echo
|
|
|
|
|
2014-06-13 12:30:14 +00:00
|
|
|
If your list of hosts is I<server1-88.example.net> with login I<foo>:
|
|
|
|
|
|
|
|
seq 10 | parallel -Sfoo@server{1..88}.example.net echo
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
To distribute the commands to a list of computers, make a file
|
|
|
|
I<mycomputers> with all the computers:
|
|
|
|
|
|
|
|
server.example.com
|
|
|
|
foo@server2.example.com
|
|
|
|
server3.example.com
|
|
|
|
|
|
|
|
Then run:
|
|
|
|
|
2011-03-09 15:23:53 +00:00
|
|
|
seq 10 | parallel --sshloginfile mycomputers echo
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
To include the local computer add the special sshlogin ':' to the list:
|
|
|
|
|
|
|
|
server.example.com
|
|
|
|
foo@server2.example.com
|
|
|
|
server3.example.com
|
|
|
|
:
|
|
|
|
|
|
|
|
GNU B<parallel> will try to determine the number of CPU cores on each
|
2011-02-23 15:22:08 +00:00
|
|
|
of the remote computers, and run one job per CPU core - even if the
|
|
|
|
remote computers do not have the same number of CPU cores.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
If the number of CPU cores on the remote computers is not identified
|
2010-12-06 23:30:08 +00:00
|
|
|
correctly the number of CPU cores can be added in front. Here the
|
2010-12-21 17:08:16 +00:00
|
|
|
computer has 8 CPU cores.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-03-09 15:23:53 +00:00
|
|
|
seq 10 | parallel --sshlogin 8/server.example.com echo
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 EXAMPLE: Transferring of files
|
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
To recompress gzipped files with B<bzip2> using a remote computer run:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
find logs/ -name '*.gz' | \
|
|
|
|
parallel --sshlogin server.example.com \
|
|
|
|
--transfer "zcat {} | bzip2 -9 >{.}.bz2"
|
|
|
|
|
|
|
|
This will list the .gz-files in the I<logs> directory and all
|
|
|
|
directories below. Then it will transfer the files to
|
|
|
|
I<server.example.com> to the corresponding directory in
|
|
|
|
I<$HOME/logs>. On I<server.example.com> the file will be recompressed
|
|
|
|
using B<zcat> and B<bzip2> resulting in the corresponding file with
|
|
|
|
I<.gz> replaced with I<.bz2>.
|
|
|
|
|
|
|
|
If you want the resulting bz2-file to be transferred back to the local
|
|
|
|
computer add I<--return {.}.bz2>:
|
|
|
|
|
|
|
|
find logs/ -name '*.gz' | \
|
|
|
|
parallel --sshlogin server.example.com \
|
|
|
|
--transfer --return {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
|
|
|
|
|
|
|
|
After the recompressing is done the I<.bz2>-file is transferred back to
|
|
|
|
the local computer and put next to the original I<.gz>-file.
|
|
|
|
|
|
|
|
If you want to delete the transferred files on the remote computer add
|
|
|
|
I<--cleanup>. This will remove both the file transferred to the remote
|
|
|
|
computer and the files transferred from the remote computer:
|
|
|
|
|
|
|
|
find logs/ -name '*.gz' | \
|
|
|
|
parallel --sshlogin server.example.com \
|
|
|
|
--transfer --return {.}.bz2 --cleanup "zcat {} | bzip2 -9 >{.}.bz2"
|
|
|
|
|
2010-12-21 17:08:16 +00:00
|
|
|
If you want run on several computers add the computers to I<--sshlogin>
|
2010-12-06 23:30:08 +00:00
|
|
|
either using ',' or multiple I<--sshlogin>:
|
|
|
|
|
|
|
|
find logs/ -name '*.gz' | \
|
|
|
|
parallel --sshlogin server.example.com,server2.example.com \
|
|
|
|
--sshlogin server3.example.com \
|
|
|
|
--transfer --return {.}.bz2 --cleanup "zcat {} | bzip2 -9 >{.}.bz2"
|
|
|
|
|
|
|
|
You can add the local computer using I<--sshlogin :>. This will disable the
|
|
|
|
removing and transferring for the local computer only:
|
|
|
|
|
|
|
|
find logs/ -name '*.gz' | \
|
|
|
|
parallel --sshlogin server.example.com,server2.example.com \
|
|
|
|
--sshlogin server3.example.com \
|
|
|
|
--sshlogin : \
|
|
|
|
--transfer --return {.}.bz2 --cleanup "zcat {} | bzip2 -9 >{.}.bz2"
|
|
|
|
|
|
|
|
Often I<--transfer>, I<--return> and I<--cleanup> are used together. They can be
|
|
|
|
shortened to I<--trc>:
|
|
|
|
|
|
|
|
find logs/ -name '*.gz' | \
|
|
|
|
parallel --sshlogin server.example.com,server2.example.com \
|
|
|
|
--sshlogin server3.example.com \
|
|
|
|
--sshlogin : \
|
|
|
|
--trc {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
|
|
|
|
|
|
|
|
With the file I<mycomputers> containing the list of computers it becomes:
|
|
|
|
|
|
|
|
find logs/ -name '*.gz' | parallel --sshloginfile mycomputers \
|
|
|
|
--trc {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
|
|
|
|
|
|
|
|
If the file I<~/.parallel/sshloginfile> contains the list of computers
|
|
|
|
the special short hand I<-S ..> can be used:
|
|
|
|
|
|
|
|
find logs/ -name '*.gz' | parallel -S .. \
|
|
|
|
--trc {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
|
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Distributing work to local and remote computers
|
|
|
|
|
|
|
|
Convert *.mp3 to *.ogg running one process per CPU core on local computer and server2:
|
|
|
|
|
2011-02-23 15:22:08 +00:00
|
|
|
parallel --trc {.}.ogg -S server2,: \
|
2014-11-11 14:51:19 +00:00
|
|
|
'mpg321 -w - {} | oggenc -q0 - -o {.}.ogg' ::: *.mp3
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2011-06-07 20:57:50 +00:00
|
|
|
=head1 EXAMPLE: Running the same command on remote computers
|
2011-05-26 21:19:58 +00:00
|
|
|
|
|
|
|
To run the command B<uptime> on remote computers you can do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --tag --nonall -S server1,server2 uptime
|
2011-05-26 21:19:58 +00:00
|
|
|
|
|
|
|
B<--nonall> reads no arguments. If you have a list of jobs you want
|
|
|
|
run on each computer you can do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --tag --onall -S server1,server2 echo ::: 1 2 3
|
2011-10-13 21:58:02 +00:00
|
|
|
|
|
|
|
Remove B<--tag> if you do not want the sshlogin added before the
|
|
|
|
output.
|
2011-05-26 21:19:58 +00:00
|
|
|
|
2011-06-07 20:57:50 +00:00
|
|
|
If you have a lot of hosts use '-j0' to access more hosts in parallel.
|
|
|
|
|
2011-05-26 21:19:58 +00:00
|
|
|
|
2015-10-04 20:25:37 +00:00
|
|
|
=head1 EXAMPLE: Using remote computers behind NAT wall
|
|
|
|
|
|
|
|
If the workers are behind a NAT wall, you need some trickery to get to
|
|
|
|
them.
|
|
|
|
|
2017-02-21 23:30:36 +00:00
|
|
|
If you can B<ssh> to a jumphost, and reach the workers from there,
|
2015-10-04 20:25:37 +00:00
|
|
|
then the obvious solution would be this, but it B<does not work>:
|
|
|
|
|
|
|
|
parallel --ssh 'ssh jumphost ssh' -S host1 echo ::: DOES NOT WORK
|
|
|
|
|
|
|
|
It does not work because the command is dequoted by B<ssh> twice where
|
|
|
|
as GNU B<parallel> only expects it to be dequoted once.
|
|
|
|
|
|
|
|
So instead put this in B<~/.ssh/config>:
|
|
|
|
|
|
|
|
Host host1 host2 host3
|
|
|
|
ProxyCommand ssh jumphost.domain nc -w 1 %h 22
|
|
|
|
|
|
|
|
It requires B<nc(netcat)> to be installed on jumphost. With this you
|
|
|
|
can simply:
|
|
|
|
|
|
|
|
parallel -S host1,host2,host3 echo ::: This does work
|
|
|
|
|
|
|
|
=head2 No jumphost, but port forwards
|
|
|
|
|
|
|
|
If there is no jumphost but each server has port 22 forwarded from the
|
|
|
|
firewall (e.g. the firewall's port 22001 = port 22 on host1, 22002 = host2,
|
|
|
|
22003 = host3) then you can use B<~/.ssh/config>:
|
|
|
|
|
|
|
|
Host host1.v
|
|
|
|
Port 22001
|
|
|
|
Host host2.v
|
|
|
|
Port 22002
|
|
|
|
Host host3.v
|
|
|
|
Port 22003
|
|
|
|
Host *.v
|
|
|
|
Hostname firewall
|
|
|
|
|
|
|
|
And then use host{1..3}.v as normal hosts:
|
|
|
|
|
|
|
|
parallel -S host1.v,host2.v,host3.v echo ::: a b c
|
|
|
|
|
|
|
|
=head2 No jumphost, no port forwards
|
|
|
|
|
|
|
|
If ports cannot be forwarded, you need some sort of VPN to traverse
|
|
|
|
the NAT-wall. TOR is one options for that, as it is very easy to get
|
|
|
|
working.
|
|
|
|
|
|
|
|
You need to install TOR and setup a hidden service. In B<torrc> put:
|
|
|
|
|
|
|
|
HiddenServiceDir /var/lib/tor/hidden_service/
|
|
|
|
HiddenServicePort 22 127.0.0.1:22
|
|
|
|
|
|
|
|
Then start TOR: B</etc/init.d/tor restart>
|
|
|
|
|
|
|
|
The TOR hostname is now in B</var/lib/tor/hidden_service/hostname> and
|
|
|
|
is something similar to B<izjafdceobowklhz.onion>. Now you simply
|
|
|
|
prepend B<torsocks> to B<ssh>:
|
|
|
|
|
|
|
|
parallel --ssh 'torsocks ssh' -S izjafdceobowklhz.onion \
|
|
|
|
-S zfcdaeiojoklbwhz.onion,auclucjzobowklhi.onion echo ::: a b c
|
|
|
|
|
|
|
|
If not all hosts are accessible through TOR:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
parallel -S 'torsocks ssh izjafdceobowklhz.onion,host2,host3' \
|
|
|
|
echo ::: a b c
|
2015-10-04 20:25:37 +00:00
|
|
|
|
2016-10-22 11:39:31 +00:00
|
|
|
See more B<ssh> tricks on https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts
|
|
|
|
|
2015-10-04 20:25:37 +00:00
|
|
|
|
2011-08-02 21:18:28 +00:00
|
|
|
=head1 EXAMPLE: Parallelizing rsync
|
|
|
|
|
|
|
|
B<rsync> is a great tool, but sometimes it will not fill up the
|
|
|
|
available bandwidth. This is often a problem when copying several big
|
|
|
|
files over high speed connections.
|
|
|
|
|
|
|
|
The following will start one B<rsync> per big file in I<src-dir> to
|
|
|
|
I<dest-dir> on the server I<fooserver>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cd src-dir; find . -type f -size +100000 | \
|
|
|
|
parallel -v ssh fooserver mkdir -p /dest-dir/{//}\; \
|
|
|
|
rsync -s -Havessh {} fooserver:/dest-dir/{}
|
2011-08-02 21:18:28 +00:00
|
|
|
|
|
|
|
The dirs created may end up with wrong permissions and smaller files
|
|
|
|
are not being transferred. To fix those run B<rsync> a final time:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
rsync -Havessh src-dir/ fooserver:/dest-dir/
|
2011-08-02 21:18:28 +00:00
|
|
|
|
2013-03-12 09:17:55 +00:00
|
|
|
If you are unable to push data, but need to pull them and the files
|
|
|
|
are called digits.png (e.g. 000000.png) you might be able to do:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
seq -w 0 99 | parallel rsync -Havessh fooserver:src/*{}.png destdir/
|
2013-03-12 09:17:55 +00:00
|
|
|
|
2011-08-02 21:18:28 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Use multiple inputs in one command
|
|
|
|
|
|
|
|
Copy files like foo.es.ext to foo.ext:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls *.es.* | perl -pe 'print; s/\.es//' | parallel -N2 cp {1} {2}
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
The perl command spits out 2 lines for each input. GNU B<parallel>
|
|
|
|
takes 2 inputs (using B<-N2>) and replaces {1} and {2} with the inputs.
|
|
|
|
|
2011-05-26 11:14:03 +00:00
|
|
|
Count in binary:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel -k echo ::: 0 1 ::: 0 1 ::: 0 1 ::: 0 1 ::: 0 1 ::: 0 1
|
2011-05-26 11:14:03 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
Print the number on the opposing sides of a six sided die:
|
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
parallel --link -a <(seq 6) -a <(seq 6 -1 1) echo
|
|
|
|
parallel --link echo :::: <(seq 6) <(seq 6 -1 1)
|
2011-05-03 22:30:56 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
Convert files from all subdirs to PNG-files with consecutive numbers
|
|
|
|
(useful for making input PNG's for B<ffmpeg>):
|
|
|
|
|
2016-08-13 17:11:15 +00:00
|
|
|
parallel --link -a <(find . -type f | sort) \
|
2014-11-11 14:51:19 +00:00
|
|
|
-a <(seq $(find . -type f|wc -l)) convert {1} {2}.png
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Alternative version:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
find . -type f | sort | parallel convert {} {#}.png
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 EXAMPLE: Use a table as input
|
|
|
|
|
|
|
|
Content of table_file.tsv:
|
|
|
|
|
|
|
|
foo<TAB>bar
|
|
|
|
baz <TAB> quux
|
|
|
|
|
|
|
|
To run:
|
|
|
|
|
|
|
|
cmd -o bar -i foo
|
|
|
|
cmd -o quux -i baz
|
|
|
|
|
|
|
|
you can run:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel -a table_file.tsv --colsep '\t' cmd -o {2} -i {1}
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Note: The default for GNU B<parallel> is to remove the spaces around the columns. To keep the spaces:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel -a table_file.tsv --trim n --colsep '\t' cmd -o {2} -i {1}
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2016-12-22 13:27:00 +00:00
|
|
|
=head1 EXAMPLE: Output to database
|
2016-12-18 10:14:06 +00:00
|
|
|
|
|
|
|
GNU B<parallel> can output to a database table and a CSV-file:
|
|
|
|
|
|
|
|
DBURL=csv:///%2Ftmp%2Fmy.csv
|
|
|
|
DBTABLEURL=$DBURL/mytable
|
|
|
|
parallel --sqlandworker $DBTABLEURL seq ::: {1..10}
|
|
|
|
|
|
|
|
It is rather slow and takes up a lot of CPU time because GNU
|
|
|
|
B<parallel> parses the whole CSV file for each update.
|
|
|
|
|
|
|
|
A better approach is to use an SQLite-base and then convert that to CSV:
|
|
|
|
|
|
|
|
DBURL=sqlite3:///%2Ftmp%2Fmy.sqlite
|
|
|
|
DBTABLEURL=$DBURL/mytable
|
|
|
|
parallel --sqlandworker $DBTABLEURL seq ::: {1..10}
|
|
|
|
sql $DBURL '.headers on' '.mode csv' 'SELECT * FROM mytable;'
|
|
|
|
|
|
|
|
This takes around a second per job.
|
|
|
|
|
|
|
|
If you have access to a real database system, such as PostgreSQL, it
|
|
|
|
is even faster:
|
|
|
|
|
|
|
|
DBURL=pg://user:pass@host/mydb
|
|
|
|
DBTABLEURL=$DBURL/mytable
|
|
|
|
parallel --sqlandworker $DBTABLEURL seq ::: {1..10}
|
|
|
|
sql $DBURL "COPY (SELECT * FROM mytable) TO stdout DELIMITER ',' CSV HEADER;"
|
|
|
|
|
|
|
|
Or MySQL:
|
|
|
|
|
|
|
|
DBURL=mysql://user:pass@host/mydb
|
|
|
|
DBTABLEURL=$DBURL/mytable
|
|
|
|
parallel --sqlandworker $DBTABLEURL seq ::: {1..10}
|
|
|
|
sql -p -B $DBURL "SELECT * FROM mytable;" > mytable.tsv
|
2017-03-21 21:20:38 +00:00
|
|
|
perl -pe 's/"/""/g; s/\t/","/g; s/^/"/; s/$/"/; s/\\\\/\\/g;
|
|
|
|
s/\\t/\t/g; s/\\n/\n/g;' mytable.tsv
|
2016-12-18 10:14:06 +00:00
|
|
|
|
|
|
|
|
2016-12-22 13:27:00 +00:00
|
|
|
=head1 EXAMPLE: Output to CSV-file for R
|
|
|
|
|
|
|
|
If you have no need for the advanced job distribution control that a
|
|
|
|
database provides, but you simply want output into a CSV file that you
|
|
|
|
can read into R or LibreCalc, then you can use B<--results>:
|
|
|
|
|
|
|
|
parallel --results my.csv seq ::: 10 20 30
|
|
|
|
R
|
|
|
|
> mydf <- read.csv("my.csv");
|
|
|
|
> print(mydf[2,])
|
|
|
|
> write(as.character(mydf[2,c("Stdout")]),'')
|
|
|
|
|
2017-01-01 11:42:52 +00:00
|
|
|
|
|
|
|
=head1 EXAMPLE: Use XML as input
|
|
|
|
|
2017-02-21 23:30:36 +00:00
|
|
|
The show Aflyttet on Radio 24syv publishes an RSS feed with their audio
|
2017-01-01 11:42:52 +00:00
|
|
|
podcasts on: http://arkiv.radio24syv.dk/audiopodcast/channel/4466232
|
|
|
|
|
|
|
|
Using B<xpath> you can extract the URLs for 2016 and download them
|
|
|
|
using GNU B<parallel>:
|
|
|
|
|
|
|
|
wget -O - http://arkiv.radio24syv.dk/audiopodcast/channel/4466232 |
|
|
|
|
xpath -e "//ancestor::pubDate[contains(text(),'2016')]/../enclosure/@url" |
|
|
|
|
parallel -u wget '{= s/ url="//; s/"//; =}'
|
|
|
|
|
|
|
|
|
2011-02-23 15:22:08 +00:00
|
|
|
=head1 EXAMPLE: Run the same command 10 times
|
|
|
|
|
|
|
|
If you want to run the same command with the same arguments 10 times
|
|
|
|
in parallel you can do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq 10 | parallel -n0 my_command my_args
|
2011-02-23 15:22:08 +00:00
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Working as cat | sh. Resource inexpensive jobs and evaluation
|
|
|
|
|
|
|
|
GNU B<parallel> can work similar to B<cat | sh>.
|
|
|
|
|
|
|
|
A resource inexpensive job is a job that takes very little CPU, disk
|
|
|
|
I/O and network I/O. Ping is an example of a resource inexpensive
|
|
|
|
job. wget is too - if the webpages are small.
|
|
|
|
|
|
|
|
The content of the file jobs_to_run:
|
|
|
|
|
|
|
|
ping -c 1 10.0.0.1
|
2011-05-03 22:30:56 +00:00
|
|
|
wget http://example.com/status.cgi?ip=10.0.0.1
|
2010-12-06 23:30:08 +00:00
|
|
|
ping -c 1 10.0.0.2
|
2011-05-03 22:30:56 +00:00
|
|
|
wget http://example.com/status.cgi?ip=10.0.0.2
|
2010-12-06 23:30:08 +00:00
|
|
|
...
|
|
|
|
ping -c 1 10.0.0.255
|
2011-05-03 22:30:56 +00:00
|
|
|
wget http://example.com/status.cgi?ip=10.0.0.255
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
To run 100 processes simultaneously do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel -j 100 < jobs_to_run
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-19 11:58:36 +00:00
|
|
|
As there is not a I<command> the jobs will be evaluated by the shell.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2011-02-02 15:36:29 +00:00
|
|
|
=head1 EXAMPLE: Processing a big file using more cores
|
|
|
|
|
|
|
|
To process a big file or some output you can use B<--pipe> to split up
|
|
|
|
the data into blocks and pipe the blocks into the processing program.
|
|
|
|
|
|
|
|
If the program is B<gzip -9> you can do:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat bigfile | parallel --pipe --recend '' -k gzip -9 > bigfile.gz
|
2011-02-02 15:36:29 +00:00
|
|
|
|
|
|
|
This will split B<bigfile> into blocks of 1 MB and pass that to B<gzip
|
|
|
|
-9> in parallel. One B<gzip> will be run per CPU core. The output of
|
|
|
|
B<gzip -9> will be kept in order and saved to B<bigfile.gz>
|
|
|
|
|
|
|
|
B<gzip> works fine if the output is appended, but some processing does
|
|
|
|
not work like that - for example sorting. For this GNU B<parallel> can
|
|
|
|
put the output of each command into a file. This will sort a big file
|
|
|
|
in parallel:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat bigfile | parallel --pipe --files sort |\
|
|
|
|
parallel -Xj1 sort -m {} ';' rm {} >bigfile.sort
|
2011-02-02 15:36:29 +00:00
|
|
|
|
|
|
|
Here B<bigfile> is split into blocks of around 1MB, each block ending
|
|
|
|
in '\n' (which is the default for B<--recend>). Each block is passed
|
|
|
|
to B<sort> and the output from B<sort> is saved into files. These
|
|
|
|
files are passed to the second B<parallel> that runs B<sort -m> on the
|
|
|
|
files before it removes the files. The output is saved to
|
|
|
|
B<bigfile.sort>.
|
|
|
|
|
2014-05-28 21:45:13 +00:00
|
|
|
GNU B<parallel>'s B<--pipe> maxes out at around 100 MB/s because every
|
|
|
|
byte has to be copied through GNU B<parallel>. But if B<bigfile> is a
|
|
|
|
real (seekable) file GNU B<parallel> can by-pass the copying and send
|
|
|
|
the parts directly to the program:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel --pipepart --block 100m -a bigfile --files sort |\
|
|
|
|
parallel -Xj1 sort -m {} ';' rm {} >bigfile.sort
|
2014-05-28 21:45:13 +00:00
|
|
|
|
2011-02-02 15:36:29 +00:00
|
|
|
|
2017-02-21 23:30:36 +00:00
|
|
|
=head1 EXAMPLE: Grouping input lines
|
|
|
|
|
|
|
|
When processing with B<--pipe> you may have lines grouped by a
|
|
|
|
value. Here is I<my.csv>:
|
|
|
|
|
|
|
|
Transaction Customer Item
|
|
|
|
1 a 53
|
|
|
|
2 b 65
|
|
|
|
3 b 82
|
|
|
|
4 c 96
|
|
|
|
5 c 67
|
|
|
|
6 c 13
|
|
|
|
7 d 90
|
|
|
|
8 d 43
|
|
|
|
9 d 91
|
|
|
|
10 d 84
|
|
|
|
11 e 72
|
|
|
|
12 e 102
|
|
|
|
13 e 63
|
|
|
|
14 e 56
|
|
|
|
15 e 74
|
|
|
|
|
|
|
|
Let us assume you want GNU B<parallel> to process each customer. In
|
|
|
|
other words: You want all the transactions for a single customer to be
|
|
|
|
treated as a single record.
|
|
|
|
|
|
|
|
To do this we preprocess the data with a program that inserts a record
|
|
|
|
separator before each customer (column 2 = $F[1]). Here we first make
|
|
|
|
a 50 character random string, which we then use as the separator:
|
|
|
|
|
|
|
|
sep=`perl -e 'print map { ("a".."z","A".."Z")[rand(52)] } (1..50);'`
|
2017-03-21 21:20:38 +00:00
|
|
|
cat my.csv | perl -ape '$F[1] ne $l and print "'$sep'"; $l = $F[1]' |
|
2017-02-21 23:30:36 +00:00
|
|
|
parallel --recend $sep --rrs --pipe -N1 wc
|
|
|
|
|
|
|
|
If your program can process multiple customers replace B<-N1> with a
|
|
|
|
reasonable B<--blocksize>.
|
|
|
|
|
|
|
|
|
2014-09-07 15:10:44 +00:00
|
|
|
=head1 EXAMPLE: Running more than 250 jobs workaround
|
2013-11-28 14:24:34 +00:00
|
|
|
|
|
|
|
If you need to run a massive amount of jobs in parallel, then you will
|
2014-09-07 15:10:44 +00:00
|
|
|
likely hit the filehandle limit which is often around 250 jobs. If you
|
2013-11-28 14:24:34 +00:00
|
|
|
are super user you can raise the limit in /etc/security/limits.conf
|
|
|
|
but you can also use this workaround. The filehandle limit is per
|
|
|
|
process. That means that if you just spawn more GNU B<parallel>s then
|
2014-09-07 15:10:44 +00:00
|
|
|
each of them can run 250 jobs. This will spawn up to 2500 jobs:
|
2013-11-28 14:24:34 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat myinput |\
|
|
|
|
parallel --pipe -N 50 --round-robin -j50 parallel -j50 your_prg
|
2013-11-28 14:24:34 +00:00
|
|
|
|
2014-09-07 15:10:44 +00:00
|
|
|
This will spawn up to 62500 jobs (use with caution - you need 64 GB
|
|
|
|
RAM to do this, and you may need to increase /proc/sys/kernel/pid_max):
|
2013-11-28 14:24:34 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat myinput |\
|
|
|
|
parallel --pipe -N 250 --round-robin -j250 parallel -j250 your_prg
|
2013-11-28 14:24:34 +00:00
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Working as mutex and counting semaphore
|
|
|
|
|
|
|
|
The command B<sem> is an alias for B<parallel --semaphore>.
|
|
|
|
|
|
|
|
A counting semaphore will allow a given number of jobs to be started
|
|
|
|
in the background. When the number of jobs are running in the
|
|
|
|
background, GNU B<sem> will wait for one of these to complete before
|
|
|
|
starting another command. B<sem --wait> will wait for all jobs to
|
|
|
|
complete.
|
|
|
|
|
|
|
|
Run 10 jobs concurrently in the background:
|
|
|
|
|
2012-06-03 20:33:00 +00:00
|
|
|
for i in *.log ; do
|
2010-12-06 23:30:08 +00:00
|
|
|
echo $i
|
|
|
|
sem -j10 gzip $i ";" echo done
|
|
|
|
done
|
|
|
|
sem --wait
|
|
|
|
|
|
|
|
A mutex is a counting semaphore allowing only one job to run. This
|
|
|
|
will edit the file I<myfile> and prepends the file with lines with the
|
|
|
|
numbers 1 to 3.
|
|
|
|
|
2011-03-09 15:23:53 +00:00
|
|
|
seq 3 | parallel sem sed -i -e 'i{}' myfile
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
As I<myfile> can be very big it is important only one process edits
|
|
|
|
the file at the same time.
|
|
|
|
|
|
|
|
Name the semaphore to have multiple different semaphores active at the
|
|
|
|
same time:
|
|
|
|
|
2011-03-09 15:23:53 +00:00
|
|
|
seq 3 | parallel sem --id mymutex sed -i -e 'i{}' myfile
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2015-01-02 10:33:40 +00:00
|
|
|
=head1 EXAMPLE: Mutex for a script
|
|
|
|
|
|
|
|
Assume a script is called from cron or from a web service, but only
|
|
|
|
one instance can be run at a time. With B<sem> and B<--shebang-wrap>
|
|
|
|
the script can be made to wait for other instances to finish. Here in
|
|
|
|
B<bash>:
|
|
|
|
|
|
|
|
#!/usr/bin/sem --shebang-wrap -u --id $0 --fg /bin/bash
|
|
|
|
|
|
|
|
echo This will run
|
|
|
|
sleep 5
|
|
|
|
echo exclusively
|
|
|
|
|
|
|
|
Here B<perl>:
|
|
|
|
|
|
|
|
#!/usr/bin/sem --shebang-wrap -u --id $0 --fg /usr/bin/perl
|
|
|
|
|
|
|
|
print "This will run ";
|
|
|
|
sleep 5;
|
|
|
|
print "exclusively\n";
|
|
|
|
|
|
|
|
Here B<python>:
|
|
|
|
|
|
|
|
#!/usr/local/bin/sem --shebang-wrap -u --id $0 --fg /usr/bin/python
|
|
|
|
|
|
|
|
import time
|
|
|
|
print "This will run ";
|
|
|
|
time.sleep(5)
|
|
|
|
print "exclusively";
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: Start editor with filenames from stdin (standard input)
|
|
|
|
|
2011-10-14 22:21:23 +00:00
|
|
|
You can use GNU B<parallel> to start interactive programs like emacs or vi:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat filelist | parallel --tty -X emacs
|
|
|
|
cat filelist | parallel --tty -X vi
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
If there are more files than will fit on a single command line, the
|
|
|
|
editor will be started again with the remaining files.
|
|
|
|
|
|
|
|
|
2011-05-13 23:03:09 +00:00
|
|
|
=head1 EXAMPLE: Running sudo
|
|
|
|
|
|
|
|
B<sudo> requires a password to run a command as root. It caches the
|
|
|
|
access, so you only need to enter the password again if you have not
|
|
|
|
used B<sudo> for a while.
|
|
|
|
|
|
|
|
The command:
|
|
|
|
|
|
|
|
parallel sudo echo ::: This is a bad idea
|
|
|
|
|
|
|
|
is no good, as you would be prompted for the sudo password for each of
|
|
|
|
the jobs. You can either do:
|
|
|
|
|
|
|
|
sudo echo This
|
|
|
|
parallel sudo echo ::: is a good idea
|
|
|
|
|
|
|
|
or:
|
|
|
|
|
|
|
|
sudo parallel echo ::: This is a good idea
|
|
|
|
|
|
|
|
This way you only have to enter the sudo password once.
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: GNU Parallel as queue system/batch manager
|
|
|
|
|
2011-01-02 00:01:21 +00:00
|
|
|
GNU B<parallel> can work as a simple job queue system or batch manager.
|
|
|
|
The idea is to put the jobs into a file and have GNU B<parallel> read
|
|
|
|
from that continuously. As GNU B<parallel> will stop at end of file we
|
|
|
|
use B<tail> to continue reading:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
true >jobqueue; tail -n+0 -f jobqueue | parallel
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
To submit your jobs to the queue:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo my_command my_arg >> jobqueue
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
You can of course use B<-S> to distribute the jobs to remote
|
|
|
|
computers:
|
|
|
|
|
2015-01-02 21:32:00 +00:00
|
|
|
true >jobqueue; tail -n+0 -f jobqueue | parallel -S ..
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2016-01-01 14:12:43 +00:00
|
|
|
If you keep this running for a long time, jobqueue will grow. A way of
|
|
|
|
removing the jobs already run is by making GNU B<parallel> stop when
|
|
|
|
it hits a special value and then restart. To use B<--eof> to make GNU
|
|
|
|
B<parallel> exit, B<tail> also needs to be forced to exit:
|
|
|
|
|
|
|
|
true >jobqueue;
|
|
|
|
while true; do
|
|
|
|
tail -n+0 -f jobqueue |
|
|
|
|
(parallel -E StOpHeRe -S ..; echo GNU Parallel is now done;
|
|
|
|
perl -e 'while(<>){/StOpHeRe/ and last};print <>' jobqueue > j2;
|
|
|
|
(seq 1000 >> jobqueue &);
|
|
|
|
echo Done appending dummy data forcing tail to exit)
|
|
|
|
echo tail exited;
|
|
|
|
mv j2 jobqueue
|
|
|
|
done
|
|
|
|
|
|
|
|
In some cases you can run on more CPUs and computers during the night:
|
|
|
|
|
|
|
|
# Day time
|
|
|
|
echo 50% > jobfile
|
|
|
|
cp day_server_list ~/.parallel/sshloginfile
|
|
|
|
# Night time
|
|
|
|
echo 100% > jobfile
|
|
|
|
cp night_server_list ~/.parallel/sshloginfile
|
|
|
|
tail -n+0 -f jobqueue | parallel --jobs jobfile -S ..
|
|
|
|
|
|
|
|
GNU Parallel discovers if B<jobfile> or B<~/.parallel/sshloginfile>
|
|
|
|
changes.
|
|
|
|
|
2013-11-02 22:17:20 +00:00
|
|
|
There is a a small issue when using GNU B<parallel> as queue
|
|
|
|
system/batch manager: You have to submit JobSlot number of jobs before
|
|
|
|
they will start, and after that you can submit one at a time, and job
|
|
|
|
will start immediately if free slots are available. Output from the
|
|
|
|
running or completed jobs are held back and will only be printed when
|
2016-08-13 17:11:15 +00:00
|
|
|
JobSlots more jobs has been started (unless you use --ungroup or
|
|
|
|
--line-buffer, in which case the output from the jobs are printed
|
|
|
|
immediately). E.g. if you have 10 jobslots then the output from the
|
|
|
|
first completed job will only be printed when job 11 has started, and
|
|
|
|
the output of second completed job will only be printed when job 12
|
|
|
|
has started.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 EXAMPLE: GNU Parallel as dir processor
|
|
|
|
|
|
|
|
If you have a dir in which users drop files that needs to be processed
|
|
|
|
you can do this on GNU/Linux (If you know what B<inotifywait> is
|
|
|
|
called on other platforms file a bug report):
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
inotifywait -qmre MOVED_TO -e CLOSE_WRITE --format %w%f my_dir |\
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel -u echo
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
This will run the command B<echo> on each file put into B<my_dir> or
|
|
|
|
subdirs of B<my_dir>.
|
|
|
|
|
|
|
|
You can of course use B<-S> to distribute the jobs to remote
|
|
|
|
computers:
|
|
|
|
|
2017-03-21 21:20:38 +00:00
|
|
|
inotifywait -qmre MOVED_TO -e CLOSE_WRITE --format %w%f my_dir |\
|
2014-11-11 14:51:19 +00:00
|
|
|
parallel -S .. -u echo
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
If the files to be processed are in a tar file then unpacking one file
|
|
|
|
and processing it immediately may be faster than first unpacking all
|
|
|
|
files. Set up the dir processor as above and unpack into the dir.
|
|
|
|
|
2013-01-14 23:20:59 +00:00
|
|
|
Using GNU Parallel as dir processor has the same limitations as using
|
|
|
|
GNU Parallel as queue system/batch manager.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=head1 QUOTING
|
|
|
|
|
2010-12-15 23:25:41 +00:00
|
|
|
GNU B<parallel> is very liberal in quoting. You only need to quote
|
|
|
|
characters that have special meaning in shell:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
( ) $ ` ' " < > ; | \
|
2010-12-15 23:25:41 +00:00
|
|
|
|
|
|
|
and depending on context these needs to be quoted, too:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
~ & # ! ? space * {
|
2010-12-15 23:25:41 +00:00
|
|
|
|
2010-12-19 00:38:36 +00:00
|
|
|
Therefore most people will never need more quoting than putting '\'
|
|
|
|
in front of the special characters.
|
|
|
|
|
2012-09-27 09:41:40 +00:00
|
|
|
Often you can simply put \' around every ':
|
|
|
|
|
2012-10-17 00:09:03 +00:00
|
|
|
perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' file
|
2012-09-27 09:41:40 +00:00
|
|
|
|
|
|
|
can be quoted:
|
|
|
|
|
2012-10-17 00:09:03 +00:00
|
|
|
parallel perl -ne \''/^\S+\s+\S+$/ and print $ARGV,"\n"'\' ::: file
|
2012-09-27 09:41:40 +00:00
|
|
|
|
2010-12-19 00:38:36 +00:00
|
|
|
However, when you want to use a shell variable you need to quote the
|
2010-12-15 23:25:41 +00:00
|
|
|
$-sign. Here is an example using $PARALLEL_SEQ. This variable is set
|
|
|
|
by GNU B<parallel> itself, so the evaluation of the $ must be done by
|
|
|
|
the sub shell started by GNU B<parallel>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq 10 | parallel -N2 echo seq:\$PARALLEL_SEQ arg1:{1} arg2:{2}
|
2010-12-15 23:25:41 +00:00
|
|
|
|
|
|
|
If the variable is set before GNU B<parallel> starts you can do this:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
VAR=this_is_set_before_starting
|
|
|
|
echo test | parallel echo {} $VAR
|
2010-12-15 23:25:41 +00:00
|
|
|
|
|
|
|
Prints: B<test this_is_set_before_starting>
|
|
|
|
|
2010-12-19 00:38:36 +00:00
|
|
|
It is a little more tricky if the variable contains more than one space in a row:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
VAR="two spaces between each word"
|
|
|
|
echo test | parallel echo {} \'"$VAR"\'
|
2010-12-19 00:38:36 +00:00
|
|
|
|
|
|
|
Prints: B<test two spaces between each word>
|
|
|
|
|
2010-12-15 23:25:41 +00:00
|
|
|
If the variable should not be evaluated by the shell starting GNU
|
|
|
|
B<parallel> but be evaluated by the sub shell started by GNU
|
|
|
|
B<parallel>, then you need to quote it:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo test | parallel VAR=this_is_set_after_starting \; echo {} \$VAR
|
2010-12-15 23:25:41 +00:00
|
|
|
|
|
|
|
Prints: B<test this_is_set_after_starting>
|
|
|
|
|
2010-12-19 00:38:36 +00:00
|
|
|
It is a little more tricky if the variable contains space:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo test |\
|
|
|
|
parallel VAR='"two spaces between each word"' echo {} \'"$VAR"\'
|
2010-12-19 00:38:36 +00:00
|
|
|
|
|
|
|
Prints: B<test two spaces between each word>
|
|
|
|
|
2010-12-15 23:25:41 +00:00
|
|
|
$$ is the shell variable containing the process id of the shell. This
|
|
|
|
will print the process id of the shell running GNU B<parallel>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq 10 | parallel echo $$
|
2010-12-15 23:25:41 +00:00
|
|
|
|
|
|
|
And this will print the process ids of the sub shells started by GNU
|
|
|
|
B<parallel>.
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq 10 | parallel echo \$\$
|
2010-12-15 23:25:41 +00:00
|
|
|
|
|
|
|
If the special characters should not be evaluated by the sub shell
|
|
|
|
then you need to protect it against evaluation from both the shell
|
|
|
|
starting GNU B<parallel> and the sub shell:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo test | parallel echo {} \\\$VAR
|
2010-12-15 23:25:41 +00:00
|
|
|
|
|
|
|
Prints: B<test $VAR>
|
|
|
|
|
|
|
|
GNU B<parallel> can protect against evaluation by the sub shell by
|
|
|
|
using -q:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo test | parallel -q echo {} \$VAR
|
2010-12-15 23:25:41 +00:00
|
|
|
|
|
|
|
Prints: B<test $VAR>
|
|
|
|
|
|
|
|
This is particularly useful if you have lots of quoting. If you want to run a perl script like this:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' file
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
It needs to be quoted like one of these:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | parallel perl -ne '/^\\S+\\s+\\S+\$/\ and\ print\ \$ARGV,\"\\n\"'
|
|
|
|
ls | parallel perl -ne \''/^\S+\s+\S+$/ and print $ARGV,"\n"'\'
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-15 23:25:41 +00:00
|
|
|
Notice how spaces, \'s, "'s, and $'s need to be quoted. GNU B<parallel>
|
|
|
|
can do the quoting by using option -q:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | parallel -q perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"'
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-15 23:25:41 +00:00
|
|
|
However, this means you cannot make the sub shell interpret special
|
2010-12-19 00:38:36 +00:00
|
|
|
characters. For example because of B<-q> this WILL NOT WORK:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls *.gz | parallel -q "zcat {} >{.}"
|
|
|
|
ls *.gz | parallel -q "zcat {} | bzip2 >{.}.bz2"
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2010-12-15 23:25:41 +00:00
|
|
|
because > and | need to be interpreted by the sub shell.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
If you get errors like:
|
|
|
|
|
|
|
|
sh: -c: line 0: syntax error near unexpected token
|
|
|
|
sh: Syntax error: Unterminated quoted string
|
|
|
|
sh: -c: line 0: unexpected EOF while looking for matching `''
|
|
|
|
sh: -c: line 1: syntax error: unexpected end of file
|
|
|
|
|
|
|
|
then you might try using B<-q>.
|
|
|
|
|
|
|
|
If you are using B<bash> process substitution like B<<(cat foo)> then
|
|
|
|
you may try B<-q> and prepending I<command> with B<bash -c>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | parallel -q bash -c 'wc -c <(echo {})'
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Or for substituting output:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
ls | parallel -q bash -c \
|
|
|
|
'tar c {} | tee >(gzip >{}.tar.gz) | bzip2 >{}.tar.bz2'
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
B<Conclusion>: To avoid dealing with the quoting problems it may be
|
2013-07-03 22:50:08 +00:00
|
|
|
easier just to write a small script or a function (remember to
|
|
|
|
B<export -f> the function) and have GNU B<parallel> call that.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 LIST RUNNING JOBS
|
|
|
|
|
|
|
|
If you want a list of the jobs currently running you can run:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
killall -USR1 parallel
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-05-26 21:19:58 +00:00
|
|
|
GNU B<parallel> will then print the currently running jobs on stderr
|
|
|
|
(standard error).
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 COMPLETE RUNNING JOBS BUT DO NOT START NEW JOBS
|
|
|
|
|
|
|
|
If you regret starting a lot of jobs you can simply break GNU B<parallel>,
|
2012-05-27 16:14:25 +00:00
|
|
|
but if you want to make sure you do not have half-completed jobs you
|
2010-12-06 23:30:08 +00:00
|
|
|
should send the signal B<SIGTERM> to GNU B<parallel>:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
killall -TERM parallel
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
This will tell GNU B<parallel> to not start any new jobs, but wait until
|
|
|
|
the currently running jobs are finished before exiting.
|
|
|
|
|
|
|
|
|
|
|
|
=head1 ENVIRONMENT VARIABLES
|
|
|
|
|
|
|
|
=over 9
|
|
|
|
|
|
|
|
=item $PARALLEL_PID
|
|
|
|
|
|
|
|
The environment variable $PARALLEL_PID is set by GNU B<parallel> and
|
|
|
|
is visible to the jobs started from GNU B<parallel>. This makes it
|
|
|
|
possible for the jobs to communicate directly to GNU B<parallel>.
|
|
|
|
Remember to quote the $, so it gets evaluated by the correct
|
|
|
|
shell.
|
|
|
|
|
|
|
|
B<Example:> If each of the jobs tests a solution and one of jobs finds
|
|
|
|
the solution the job can tell GNU B<parallel> not to start more jobs
|
|
|
|
by: B<kill -TERM $PARALLEL_PID>. This only works on the local
|
|
|
|
computer.
|
|
|
|
|
|
|
|
|
2014-11-23 00:31:33 +00:00
|
|
|
=item $PARALLEL_SHELL
|
2014-10-22 19:59:06 +00:00
|
|
|
|
|
|
|
Use this shell the shell for the commands run by GNU Parallel:
|
|
|
|
|
|
|
|
=over 2
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
|
|
|
$PARALLEL_SHELL. If undefined use:
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
|
|
|
The shell that started GNU Parallel. If that cannot be determined:
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
|
|
|
$SHELL. If undefined use:
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
|
|
|
/bin/sh
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
2015-07-29 00:19:51 +00:00
|
|
|
=item $PARALLEL_SSH
|
2015-05-10 20:23:13 +00:00
|
|
|
|
|
|
|
GNU B<parallel> defaults to using B<ssh> for remote access. This can
|
2015-05-10 20:52:47 +00:00
|
|
|
be overridden with $PARALLEL_SSH, which again can be overridden with
|
|
|
|
B<--ssh>. It can also be set on a per server basis (see
|
|
|
|
B<--sshlogin>).
|
2015-05-10 20:23:13 +00:00
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item $PARALLEL_SEQ
|
|
|
|
|
|
|
|
$PARALLEL_SEQ will be set to the sequence number of the job
|
|
|
|
running. Remember to quote the $, so it gets evaluated by the correct
|
|
|
|
shell.
|
|
|
|
|
|
|
|
B<Example:>
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
seq 10 | parallel -N2 \
|
|
|
|
echo seq:'$'PARALLEL_SEQ arg1:{1} arg2:{2}
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2016-10-30 16:07:59 +00:00
|
|
|
=item $PARALLEL_TMUX
|
|
|
|
|
|
|
|
Path to B<tmux>. If unset the B<tmux> in $PATH is used.
|
|
|
|
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=item $TMPDIR
|
|
|
|
|
|
|
|
Directory for temporary files. See: B<--tmpdir>.
|
|
|
|
|
|
|
|
|
|
|
|
=item $PARALLEL
|
|
|
|
|
|
|
|
The environment variable $PARALLEL will be used as default options for
|
|
|
|
GNU B<parallel>. If the variable contains special shell characters
|
|
|
|
(e.g. $, *, or space) then these need to be to be escaped with \.
|
|
|
|
|
|
|
|
B<Example:>
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat list | parallel -j1 -k -v ls
|
|
|
|
cat list | parallel -j1 -k -v -S"myssh user@server" ls
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
can be written as:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
cat list | PARALLEL="-kvj1" parallel ls
|
|
|
|
cat list | PARALLEL='-kvj1 -S myssh\ user@server' \
|
|
|
|
parallel echo
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Notice the \ in the middle is needed because 'myssh' and 'user@server'
|
|
|
|
must be one argument.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 DEFAULT PROFILE (CONFIG FILE)
|
|
|
|
|
2014-09-18 20:09:20 +00:00
|
|
|
The global configuration file /etc/parallel/config, followed by user
|
|
|
|
configuration file ~/.parallel/config (formerly known as .parallelrc)
|
|
|
|
will be read in turn if they exist. Lines starting with '#' will be
|
|
|
|
ignored. The format can follow that of the environment variable
|
|
|
|
$PARALLEL, but it is often easier to simply put each option on its own
|
|
|
|
line.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-09-18 20:09:20 +00:00
|
|
|
Options on the command line take precedence, followed by the
|
|
|
|
environment variable $PARALLEL, user configuration file
|
|
|
|
~/.parallel/config, and finally the global configuration file
|
|
|
|
/etc/parallel/config.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2014-09-18 20:09:20 +00:00
|
|
|
Note that no file that is read for options, nor the environment
|
|
|
|
variable $PARALLEL, may contain retired options such as B<--tollef>.
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 PROFILE FILES
|
|
|
|
|
2014-09-18 20:09:20 +00:00
|
|
|
If B<--profile> set, GNU B<parallel> will read the profile from that
|
|
|
|
file rather than the global or user configuration files. You can have
|
|
|
|
multiple B<--profiles>.
|
2011-10-13 21:58:02 +00:00
|
|
|
|
|
|
|
Example: Profile for running a command on every sshlogin in
|
|
|
|
~/.ssh/sshlogins and prepend the output with the sshlogin:
|
|
|
|
|
|
|
|
echo --tag -S .. --nonall > ~/.parallel/n
|
|
|
|
parallel -Jn uptime
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-02-23 15:22:08 +00:00
|
|
|
Example: Profile for running every command with B<-j-1> and B<nice>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-02-23 15:22:08 +00:00
|
|
|
echo -j-1 nice > ~/.parallel/nice_profile
|
2010-12-06 23:30:08 +00:00
|
|
|
parallel -J nice_profile bzip2 -9 ::: *
|
|
|
|
|
|
|
|
Example: Profile for running a perl script before every command:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo "perl -e '\$a=\$\$; print \$a,\" \",'\$PARALLEL_SEQ',\" \";';" \
|
|
|
|
> ~/.parallel/pre_perl
|
2010-12-06 23:30:08 +00:00
|
|
|
parallel -J pre_perl echo ::: *
|
|
|
|
|
|
|
|
Note how the $ and " need to be quoted using \.
|
|
|
|
|
|
|
|
Example: Profile for running distributed jobs with B<nice> on the
|
2010-12-21 17:08:16 +00:00
|
|
|
remote computers:
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
echo -S .. nice > ~/.parallel/dist
|
|
|
|
parallel -J dist --trc {.}.bz2 bzip2 -9 ::: *
|
|
|
|
|
|
|
|
|
|
|
|
=head1 EXIT STATUS
|
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
Exit status depends on B<--halt-on-error> if one of these are used:
|
|
|
|
success=X, success=Y%, fail=Y%.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=over 6
|
|
|
|
|
2013-07-26 12:58:42 +00:00
|
|
|
=item Z<>0
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
All jobs ran without error. If success=X is used: X jobs ran without
|
|
|
|
error. If success=Y% is used: Y% of the jobs ran without error.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
=item Z<>1-100
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
Some of the jobs failed. The exit status gives the number of failed
|
|
|
|
jobs. If Y% is used the exit status is the percentage of jobs that
|
|
|
|
failed.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
=item Z<>101
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
More than 100 jobs failed.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2013-07-26 12:58:42 +00:00
|
|
|
=item Z<>255
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Other error.
|
|
|
|
|
2016-01-01 14:12:43 +00:00
|
|
|
=item Z<>-1 (In joblog and SQL table)
|
|
|
|
|
|
|
|
Killed by Ctrl-C, timeout, not enough memory or similar.
|
|
|
|
|
|
|
|
=item Z<>-2 (In joblog and SQL table)
|
|
|
|
|
2017-02-05 01:46:29 +00:00
|
|
|
skip() was called in B<{= =}>.
|
2016-01-01 14:12:43 +00:00
|
|
|
|
2016-03-20 22:57:25 +00:00
|
|
|
=item Z<>-1000 (In SQL table)
|
2016-01-01 14:12:43 +00:00
|
|
|
|
2016-03-20 22:57:25 +00:00
|
|
|
Job is ready to run (set by --sqlmaster).
|
2016-01-01 14:12:43 +00:00
|
|
|
|
|
|
|
=item Z<>-1220 (In SQL table)
|
|
|
|
|
2016-03-20 22:57:25 +00:00
|
|
|
Job is taken by worker (set by --sqlworker).
|
2016-01-01 14:12:43 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=back
|
|
|
|
|
2015-05-10 13:02:07 +00:00
|
|
|
If fail=1 is used, the exit status will be the exit status of the
|
|
|
|
failing job.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 DIFFERENCES BETWEEN GNU Parallel AND ALTERNATIVES
|
|
|
|
|
2017-01-01 11:42:52 +00:00
|
|
|
See: B<man parallel_alternatives>
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 BUGS
|
|
|
|
|
|
|
|
=head2 Quoting of newline
|
|
|
|
|
|
|
|
Because of the way newline is quoted this will not work:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo 1,2,3 | parallel -vkd, "echo 'a{}b'"
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2011-03-14 16:37:30 +00:00
|
|
|
However, these will all work:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
echo 1,2,3 | parallel -vkd, echo a{}b
|
|
|
|
echo 1,2,3 | parallel -vkd, "echo 'a'{}'b'"
|
|
|
|
echo 1,2,3 | parallel -vkd, "echo 'a'"{}"'b'"
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
2012-02-26 01:14:46 +00:00
|
|
|
=head2 Speed
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2012-02-26 01:14:46 +00:00
|
|
|
=head3 Startup
|
|
|
|
|
2014-06-25 23:16:54 +00:00
|
|
|
GNU B<parallel> is slow at starting up - around 250 ms the first time
|
|
|
|
and 150 ms after that.
|
2012-02-26 01:14:46 +00:00
|
|
|
|
|
|
|
=head3 Job startup
|
|
|
|
|
2014-09-07 15:10:44 +00:00
|
|
|
Starting a job on the local machine takes around 10 ms. This can be a
|
2012-03-12 22:38:38 +00:00
|
|
|
big overhead if the job takes very few ms to run. Often you can group
|
|
|
|
small jobs together using B<-X> which will make the overhead less
|
2014-06-25 23:16:54 +00:00
|
|
|
significant. Or you can run multiple GNU B<parallel>s as described in
|
|
|
|
B<EXAMPLE: Speeding up fast jobs>.
|
2012-02-26 01:14:46 +00:00
|
|
|
|
|
|
|
=head3 SSH
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
When using multiple computers GNU B<parallel> opens B<ssh> connections
|
|
|
|
to them to figure out how many connections can be used reliably
|
2014-03-22 20:41:14 +00:00
|
|
|
simultaneously (Namely SSHD's MaxStartups). This test is done for each
|
2012-02-26 01:14:46 +00:00
|
|
|
host in serial, so if your B<--sshloginfile> contains many hosts it may
|
2010-12-06 23:30:08 +00:00
|
|
|
be slow.
|
|
|
|
|
2012-03-12 22:38:38 +00:00
|
|
|
If your jobs are short you may see that there are fewer jobs running
|
|
|
|
on the remove systems than expected. This is due to time spent logging
|
|
|
|
in and out. B<-M> may help here.
|
|
|
|
|
2012-02-26 01:14:46 +00:00
|
|
|
=head3 Disk access
|
|
|
|
|
|
|
|
A single disk can normally read data faster if it reads one file at a
|
|
|
|
time instead of reading a lot of files in parallel, as this will avoid
|
|
|
|
disk seeks. However, newer disk systems with multiple drives can read
|
|
|
|
faster if reading from multiple files in parallel.
|
|
|
|
|
|
|
|
If the jobs are of the form read-all-compute-all-write-all, so
|
|
|
|
everything is read before anything is written, it may be faster to
|
|
|
|
force only one disk access at the time:
|
|
|
|
|
|
|
|
sem --id diskio cat file | compute | sem --id diskio cat > file
|
|
|
|
|
|
|
|
If the jobs are of the form read-compute-write, so writing starts
|
|
|
|
before all reading is done, it may be faster to force only one reader
|
|
|
|
and writer at the time:
|
|
|
|
|
|
|
|
sem --id read cat file | compute | sem --id write cat > file
|
|
|
|
|
|
|
|
If the jobs are of the form read-compute-read-compute, it may be
|
|
|
|
faster to run more jobs in parallel than the system has CPUs, as some
|
|
|
|
of the jobs will be stuck waiting for disk access.
|
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head2 --nice limits command length
|
|
|
|
|
|
|
|
The current implementation of B<--nice> is too pessimistic in the max
|
|
|
|
allowed command length. It only uses a little more than half of what
|
2012-02-26 01:14:46 +00:00
|
|
|
it could. This affects B<-X> and B<-m>. If this becomes a real problem for
|
2010-12-06 23:30:08 +00:00
|
|
|
you file a bug-report.
|
|
|
|
|
2011-04-23 12:01:22 +00:00
|
|
|
=head2 Aliases and functions do not work
|
|
|
|
|
|
|
|
If you get:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
Can't exec "command": No such file or directory
|
2011-04-23 12:01:22 +00:00
|
|
|
|
|
|
|
or:
|
|
|
|
|
2014-11-11 14:51:19 +00:00
|
|
|
open3: exec of by command failed
|
2011-04-23 12:01:22 +00:00
|
|
|
|
|
|
|
it may be because I<command> is not known, but it could also be
|
2012-03-12 22:38:38 +00:00
|
|
|
because I<command> is an alias or a function. If it is a function you
|
2016-08-03 21:42:15 +00:00
|
|
|
need to B<export -f> the function first. An alias will only work if
|
|
|
|
you use B<env_parallel>.
|
2011-04-23 12:01:22 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=head1 REPORTING BUGS
|
|
|
|
|
2011-03-14 16:37:30 +00:00
|
|
|
Report bugs to <bug-parallel@gnu.org> or
|
|
|
|
https://savannah.gnu.org/bugs/?func=additem&group=parallel
|
2010-12-06 23:30:08 +00:00
|
|
|
|
2015-01-11 22:08:23 +00:00
|
|
|
See a perfect bug report on
|
|
|
|
https://lists.gnu.org/archive/html/bug-parallel/2015-01/msg00000.html
|
|
|
|
|
2011-08-09 20:00:31 +00:00
|
|
|
Your bug report should always include:
|
2011-03-20 21:40:12 +00:00
|
|
|
|
|
|
|
=over 2
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
2012-12-20 14:01:49 +00:00
|
|
|
The error message you get (if any).
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
2013-09-28 13:59:03 +00:00
|
|
|
The complete output of B<parallel --version>. If you are not running
|
2015-01-06 22:25:23 +00:00
|
|
|
the latest released version (see http://ftp.gnu.org/gnu/parallel/) you
|
|
|
|
should specify why you believe the problem is not fixed in that
|
|
|
|
version.
|
2011-03-20 21:40:12 +00:00
|
|
|
|
|
|
|
=item *
|
|
|
|
|
2015-09-21 18:03:52 +00:00
|
|
|
A minimal, complete, and verifiable example (See description on
|
|
|
|
http://stackoverflow.com/help/mcve).
|
|
|
|
|
|
|
|
It should be a complete example that others can run that shows the problem
|
2015-01-06 22:25:23 +00:00
|
|
|
including all files needed to run the example. This should preferably
|
2015-06-14 21:43:58 +00:00
|
|
|
be small and simple, so try to remove as many options as possible. A
|
|
|
|
combination of B<yes>, B<seq>, B<cat>, B<echo>, and B<sleep> can
|
|
|
|
reproduce most errors. If your example requires large files, see if
|
|
|
|
you can make them by something like B<seq 1000000> > B<file> or B<yes
|
2016-10-30 16:07:59 +00:00
|
|
|
| head -n 10000000> > B<file>.
|
|
|
|
|
|
|
|
If your example requires remote execution, see if you can use
|
|
|
|
B<localhost> - maybe using another login.
|
2011-03-20 21:40:12 +00:00
|
|
|
|
2012-06-28 15:19:47 +00:00
|
|
|
=item *
|
|
|
|
|
|
|
|
The output of your example. If your problem is not easily reproduced
|
|
|
|
by others, the output might help them figure out the problem.
|
|
|
|
|
2013-09-28 13:59:03 +00:00
|
|
|
=item *
|
|
|
|
|
|
|
|
Whether you have watched the intro videos
|
|
|
|
(http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1), walked
|
|
|
|
through the tutorial (man parallel_tutorial), and read the EXAMPLE
|
|
|
|
section in the man page (man parallel - search for EXAMPLE:).
|
|
|
|
|
2011-03-20 21:40:12 +00:00
|
|
|
=back
|
|
|
|
|
2012-12-20 14:01:49 +00:00
|
|
|
If you suspect the error is dependent on your environment or
|
|
|
|
distribution, please see if you can reproduce the error on one of
|
|
|
|
these VirtualBox images:
|
2012-03-15 20:23:53 +00:00
|
|
|
http://sourceforge.net/projects/virtualboximage/files/
|
2016-10-30 16:07:59 +00:00
|
|
|
http://www.osboxes.org/virtualbox-images/
|
2012-03-15 20:23:53 +00:00
|
|
|
|
|
|
|
Specifying the name of your distribution is not enough as you may have
|
|
|
|
installed software that is not in the VirtualBox images.
|
2011-11-15 00:15:23 +00:00
|
|
|
|
2012-06-28 15:19:47 +00:00
|
|
|
If you cannot reproduce the error on any of the VirtualBox images
|
2014-11-11 03:56:55 +00:00
|
|
|
above, see if you can build a VirtualBox image on which you can
|
|
|
|
reproduce the error. If not you should assume the debugging will be
|
|
|
|
done through you. That will put more burden on you and it is extra
|
|
|
|
important you give any information that help. In general the problem
|
|
|
|
will be fixed faster and with less work for you if you can reproduce
|
|
|
|
the error on a VirtualBox.
|
2012-06-28 15:19:47 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
2011-10-14 22:21:23 +00:00
|
|
|
When using GNU B<parallel> for a publication please cite:
|
2011-03-14 16:37:30 +00:00
|
|
|
|
|
|
|
O. Tange (2011): GNU Parallel - The Command-Line Power Tool, ;login:
|
|
|
|
The USENIX Magazine, February 2011:42-47.
|
|
|
|
|
2015-02-22 14:09:26 +00:00
|
|
|
This helps funding further development; and it won't cost you a cent.
|
|
|
|
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.
|
2014-10-07 22:27:13 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
Copyright (C) 2007-10-18 Ole Tange, http://ole.tange.dk
|
|
|
|
|
|
|
|
Copyright (C) 2008,2009,2010 Ole Tange, http://ole.tange.dk
|
|
|
|
|
2017-01-01 16:51:14 +00:00
|
|
|
Copyright (C) 2010,2011,2012,2013,2014,2015,2016,2017 Ole Tange,
|
2015-02-22 14:09:26 +00:00
|
|
|
http://ole.tange.dk and Free Software Foundation, Inc.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
Parts of the manual concerning B<xargs> compatibility is inspired by
|
|
|
|
the manual of B<xargs> from GNU findutils 4.4.2.
|
|
|
|
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
2016-03-26 09:35:13 +00:00
|
|
|
Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Free
|
2015-02-22 14:09:26 +00:00
|
|
|
Software Foundation, Inc.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
at your option any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
=head2 Documentation license I
|
|
|
|
|
|
|
|
Permission is granted to copy, distribute and/or modify this documentation
|
|
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
|
|
any later version published by the Free Software Foundation; with no
|
|
|
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
|
|
|
Texts. A copy of the license is included in the file fdl.txt.
|
|
|
|
|
|
|
|
=head2 Documentation license II
|
|
|
|
|
|
|
|
You are free:
|
|
|
|
|
|
|
|
=over 9
|
|
|
|
|
|
|
|
=item B<to Share>
|
|
|
|
|
|
|
|
to copy, distribute and transmit the work
|
|
|
|
|
|
|
|
=item B<to Remix>
|
|
|
|
|
|
|
|
to adapt the work
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
Under the following conditions:
|
|
|
|
|
|
|
|
=over 9
|
|
|
|
|
|
|
|
=item B<Attribution>
|
|
|
|
|
|
|
|
You must attribute the work in the manner specified by the author or
|
|
|
|
licensor (but not in any way that suggests that they endorse you or
|
|
|
|
your use of the work).
|
|
|
|
|
|
|
|
=item B<Share Alike>
|
|
|
|
|
|
|
|
If you alter, transform, or build upon this work, you may distribute
|
|
|
|
the resulting work only under the same, similar or a compatible
|
|
|
|
license.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
With the understanding that:
|
|
|
|
|
|
|
|
=over 9
|
|
|
|
|
|
|
|
=item B<Waiver>
|
|
|
|
|
|
|
|
Any of the above conditions can be waived if you get permission from
|
|
|
|
the copyright holder.
|
|
|
|
|
|
|
|
=item B<Public Domain>
|
|
|
|
|
|
|
|
Where the work or any of its elements is in the public domain under
|
|
|
|
applicable law, that status is in no way affected by the license.
|
|
|
|
|
|
|
|
=item B<Other Rights>
|
|
|
|
|
|
|
|
In no way are any of the following rights affected by the license:
|
|
|
|
|
|
|
|
=over 2
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
|
|
|
Your fair dealing or fair use rights, or other applicable
|
|
|
|
copyright exceptions and limitations;
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
|
|
|
The author's moral rights;
|
|
|
|
|
|
|
|
=item *
|
|
|
|
|
|
|
|
Rights other persons may have either in the work itself or in
|
|
|
|
how the work is used, such as publicity or privacy rights.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=over 9
|
|
|
|
|
|
|
|
=item B<Notice>
|
|
|
|
|
|
|
|
For any reuse or distribution, you must make clear to others the
|
|
|
|
license terms of this work.
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
A copy of the full license is included in the file as cc-by-sa.txt.
|
|
|
|
|
2011-04-07 19:54:02 +00:00
|
|
|
|
2010-12-06 23:30:08 +00:00
|
|
|
=head1 DEPENDENCIES
|
|
|
|
|
|
|
|
GNU B<parallel> uses Perl, and the Perl modules Getopt::Long,
|
|
|
|
IPC::Open3, Symbol, IO::File, POSIX, and File::Temp. For remote usage
|
2011-04-07 19:54:02 +00:00
|
|
|
it also uses rsync with ssh.
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
2016-05-25 22:13:48 +00:00
|
|
|
B<ssh>(1), B<ssh-agent>(1), B<sshpass>(1), B<ssh-copy-id>(1),
|
|
|
|
B<rsync>(1), B<find>(1), B<xargs>(1), B<dirname>(1), B<make>(1),
|
|
|
|
B<pexec>(1), B<ppss>(1), B<xjobs>(1), B<prll>(1), B<dxargs>(1),
|
|
|
|
B<mdm>(1)
|
2010-12-06 23:30:08 +00:00
|
|
|
|
|
|
|
=cut
|