parallel - build and execute shell command lines from standard input in parallel
parallel [options] [command [arguments]] < list_of_arguments
parallel [options] [command [arguments]] ::: arguments
parallel [options] [command [arguments]] :::: argfile(s)
parallel --semaphore [options] command
#!/usr/bin/parallel --shebang [options] [command [arguments]]
GNU parallel is a shell tool for executing jobs in parallel using one or more computers. A job is can be a single command or a small 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 parallel can then split the input and pipe it into commands in parallel.
If you use xargs and tee today you will find GNU parallel very easy to use as GNU parallel is written to have the same options as xargs. If you write loops in shell, you will find GNU parallel may be able to replace most of the loops and make them run faster by running several jobs in parallel.
GNU 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 parallel as input for other programs.
For each line of input GNU parallel will execute command with the line as arguments. If no command is given, the line of input is executed. Several lines will be run in parallel. GNU parallel can often be used as a substitute for xargs or cat | bash.
Before looking at the options you may want to check out the EXAMPLEs after the list of options. That will give you an idea of what GNU parallel is capable of.
You can also watch the intro video for a quick introduction: http://www.youtube.com/watch?v=OpaiGYxkSuQ or at http://tinyogg.com/watch/TORaR/ http://tinyogg.com/watch/hfxKj/ and http://tinyogg.com/watch/YQuXd/
If command is given, GNU parallel will behave similar to xargs. If command is not given GNU parallel will behave similar to cat | sh.
The command must be an executable, a script or a composed command: an alias or a function will not work (see why http://www.perlmonks.org/index.pl?node_id=484296).
{.} can be used the same places as {}. The replacement string {.} can be changed with -U.
{/} can be used the same places as {}. The replacement string {/} can be changed with --basenamereplace.
{/.} can be used the same places as {}. The replacement string {/.} can be changed with --basenameextensionreplace.
The replacement string {#} can be changed with --seqreplace.
{n} can be used the same places as {}.
{n.} can be used the same places as {n}.
{n/} can be used the same places as {n}.
{n/.} can be used the same places as {n}.
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 ::: as special use --arg-sep to set the argument separator to something else. See also --arg-sep.
stdin (standard input) will be passed to the first process run.
If --arg-file is set arguments from that file will be appended.
See -a.
If multiple -a are given, one line will be read from each of the files. The arguments can be accessed in the command as {1} .. {n}, so {1} will be a line from the first file, and {6} will refer to the line with the same line number from the 6th file.
See also: ::::.
Also useful if you command uses ::: but you still want to read arguments from stdin (standard input): Simply change --arg-sep to a string that is not in the command line.
See also: :::.
See also: --fg
Implies --semaphore.
GNU parallel tries to meet the block size but can be off by the length of one record.
size defaults to 1M.
See --pipe for use of this.
find log -name '*gz' | parallel \ --sshlogin server.example.com --transfer --return {.}.bz2 \ --cleanup "zcat {} | bzip -9 >{.}.bz2"
With --transfer 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.
With --return the file transferred from the remote computer will be removed on the remote computer. Directories created will not be removed - even if they are empty.
--cleanup is ignored when not used with --transfer or --return.
--colsep implies --trim rl.
regexp is a Perl Regular Expression: http://perldoc.perl.org/perlre.html
See also: --bg
Implies --semaphore.
To convert the times into ISO-8601 strict do:
perl -a -F``\t'' -ne 'chomp($F[2]=`date -d \@$F[2] +%FT%T`); print join(``\t'',@F)'
If --semaphore is set default is 1 thus making a mutex.
-L 0 means read one line, but insert 0 arguments on the command line.
Implies -X unless -m is set.
-l 0 is an alias for -l 1.
Implies -X unless -m is set.
The load average is only sampled every 10 seconds to avoid stressing small computers.
Support for -m with --sshlogin is limited and may fail.
See also -X for context replace. If in doubt use -X as that will most likely do what is needed.
The block size is determined by --block. The strings --recstart and --recend tell GNU 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 prepended to next block.
If --recstart is given this will be used to split at record start.
If --recend is given this will be used to split at record end.
If both --recstart and --recend are given both will have to match to find a split position.
If neither --recstart nor --recend are given --recend defaults to '\n'. To have no record separator use --recend ``''.
--files is often used with --pipe.
By sending GNU parallel SIGUSR2 you can toggle turning on/off --progress on a running GNU parallel process.
-n 0 means read one argument, but insert 0 arguments on the command line.
Implies -X unless -m is set.
-N 0 means read one argument, but insert 0 arguments on the command line.
This will set the owner of the homedir to the user:
tr ':' '\012' < /etc/passwd | parallel -N7 chown {1} {6}
Implies -X unless -m or <--pipe> is set.
When used with --pipe -N is the number of records to read. This is much slower than --blocksize so avoid it if performance is important.
profilename corresponds to the file ~/.parallel/profilename.
Default: config
If --recend is given endstring will be used to split at record end.
If both --recstart and --recend are given the string startstringendstring will have to match to find a split position. This is useful if either startstring or endstring match in the middle of a record.
If neither --recstart nor --recend are given then --recend defaults to '\n'. To have no record separator use --recend ``''.
--recstart and --recend are used with --pipe.
Use --regexp to interpret --recstart and --recend as regular expressions. This is slow, however.
Only used with --pipe.
echo foo/bar.txt | parallel \ --sshlogin server.example.com --return {.}.out touch {.}.out
This will transfer the file $HOME/foo/bar.out from the computer server.example.com to the file foo/bar.out after running touch foo/bar.out on server.example.com.
echo /tmp/foo/bar.txt | parallel \ --sshlogin server.example.com --return {.}.out touch {.}.out
This will transfer the file /tmp/foo/bar.out from the computer server.example.com to the file /tmp/foo/bar.out after running touch /tmp/foo/bar.out on server.example.com.
Multiple files can be transferred by repeating the options multiple times:
echo /tmp/foo/bar.txt | \ parallel --sshlogin server.example.com \ --return {.}.out --return {.}.out2 touch {.}.out {.}.out2
--return is often used with --transfer and --cleanup.
--return is ignored when used with --sshlogin : or when not used with --sshlogin.
Implies -X unless -m is set.
--semaphore implies --bg unless --fg is specified.
--semaphore implies --semaphorename `tty` unless --semaphorename is specified.
Used with --fg, --wait, and --semaphorename.
The command sem is an alias for parallel --semaphore.
Implies --semaphore.
Implies --semaphore.
An sshlogin is of the form:
[sshcommand [options]][username@]hostname
The sshlogin must not require a password.
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
To specify more sshlogins separate the sshlogins by comma or repeat the options multiple times.
For examples: see --sshloginfile.
The remote host must have GNU parallel installed.
--sshlogin is known to cause problems with -m and -X.
--sshlogin is often used with --transfer, --return, --cleanup, and --trc.
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 //usr/local/bin/myssh -p 2222 -l myusername hexacpu.example.net # Use a different ssh program with 6 cores 6//usr/local/bin/myssh -p 2222 -l myusername hexacpu.example.net # Assume 16 cores on the local computer 16/:
When using a different ssh program the last argument must be the hostname.
The sshloginfile '..' is special, it read sshlogins from ~/.parallel/sshloginfile
See also -v and -p.
echo foo/bar.txt | parallel \ --sshlogin server.example.com --transfer wc
This will transfer the file foo/bar.txt to the computer server.example.com to the file $HOME/foo/bar.txt before running wc foo/bar.txt on server.example.com.
echo /tmp/foo/bar.txt | parallel \ --sshlogin server.example.com --transfer wc
This will transfer the file foo/bar.txt to the computer server.example.com to the file /tmp/foo/bar.txt before running wc /tmp/foo/bar.txt on server.example.com.
--transfer is often used with --return and --cleanup.
--transfer is ignored when used with --sshlogin : or when not used with --sshlogin.
--transfer --return filename --cleanup
Use -v -v to print the wrapping ssh command when running remotely.
Implies --semaphore.
Normally -X will do the right thing, whereas -m can give unexpected results if {} is used as part of a word.
Support for -X with --sshlogin is limited and may fail.
See also -m.
#!/usr/bin/parallel -Yr traceroute
foss.org.my debian.org freenetproject.org
For this to work --shebang or -Y must be set as the first option.
GNU parallel can work similar to xargs -n1.
To compress all html files using gzip run:
find . -name '*.html' | parallel gzip
If the file names may contain a newline use -0. Substitute FOO BAR with FUBAR in all files in this dir and subdirs:
find . -type f -print0 | parallel -q0 perl -i -pe 's/FOO BAR/FUBAR/g'
Note -q is needed because of the space in 'FOO BAR'.
GNU parallel can take the arguments from command line instead of stdin (standard input). To compress all html files in the current dir using gzip run:
parallel gzip ::: *.html
To convert *.wav to *.mp3 using LAME running one process per CPU core run:
parallel lame {} -o {.}.mp3 ::: *.wav
When moving a lot of files like this: mv * destdir you will sometimes get the error:
bash: /bin/mv: Argument list too long
because there are too many files. You can instead do:
ls | parallel mv {} destdir
This will run mv for each file. It can be done faster if mv gets as many arguments that will fit on the line:
ls | parallel -m mv {} destdir
To remove the files pict0000.jpg .. pict9999.jpg you could do:
seq -w 0 9999 | parallel rm pict{}.jpg
You could also do:
seq -w 0 9999 | perl -pe 's/(.*)/pict$1.jpg/' | parallel -m rm
The first will run rm 10000 times, while the last will only run rm as many times needed to keep the command line length short enough to avoid Argument list too long (it typically runs 1-2 times).
You could also run:
seq -w 0 9999 | parallel -X rm pict{}.jpg
This will also only run rm as many times needed to keep the command line length short enough.
If ImageMagick is installed this will generate a thumbnail of a jpg file:
convert -geometry 120 foo.jpg thumb_foo.jpg
This will run with number-of-cpu-cores jobs in parallel for all jpg files in a directory:
ls *.jpg | parallel convert -geometry 120 {} thumb_{}
To do it recursively use find:
find . -name '*.jpg' | parallel convert -geometry 120 {} {}_thumb.jpg
Notice how the argument has to start with {} as {} will include path (e.g. running 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 {.} to avoid the extra .jpg in the file name. This command will make files like ./foo/bar_thumb.jpg:
find . -name '*.jpg' | parallel convert -geometry 120 {} {.}_thumb.jpg
This will generate an uncompressed version of .gz-files next to the .gz-file:
parallel zcat {} ``>''{.} ::: *.gz
Quoting of > is necessary to postpone the redirection. Another solution is to quote the whole command:
parallel ``zcat {} >{.}'' ::: *.gz
Other special shell charaters (such as * ; $ > < | >> <<) also needs to be put in quotes, as they may otherwise be interpreted by the shell and not given to GNU parallel.
A job can consist of several commands. This will print the number of files in each directory:
ls | parallel 'echo -n {}`` ''; ls {}|wc -l'
To put the output in a file called <name>.dir:
ls | parallel '(echo -n {}`` ''; ls {}|wc -l) > {}.dir'
Even small shell scripts can be run by GNU parallel:
find . | parallel 'a={}; name=${a##*/}; upper=$(echo ``$name'' | tr ``[:lower:]'' ``[:upper:]''); echo ``$name - $upper'''
ls | parallel 'mv {} ``$(echo {} | tr ''[:upper:]`` ''[:lower:]``)'''
Given a list of URLs, list all URLs that fail to download. Print the line number and the URL.
cat urlfile | parallel ``wget {} 2>/dev/null || grep -n {} urlfile''
Create a mirror directory with the same filenames except all files and symlinks are empty files.
cp -rs /the/source/dir mirror_dir; find mirror_dir -type l | parallel -m rm {} '&&' touch {}
When processing files removing the file extension using {.} is often useful.
Create a directory for each zip-file and unzip it in that dir:
parallel 'mkdir {.}; cd {.}; unzip ../{}' ::: *.zip
Recompress all .gz files in current directory using bzip2 running 1 job per CPU core in parallel:
parallel ``zcat {} | bzip2 >{.}.bz2 && rm {}'' ::: *.gz
Convert all WAV files to MP3 using LAME:
find sounddir -type f -name '*.wav' | parallel lame {} -o {.}.mp3
Put all converted in the same directory:
find sounddir -type f -name '*.wav' | parallel lame {} -o mydir/{/.}.mp3
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:
ls *.tar.gz| parallel -U {tar} 'echo {tar}|parallel ``mkdir -p {.} ; tar -C {.} -xf {.}.tar.gz'''
Let us assume a website stores images like:
http://www.example.com/path/to/YYYYMMDD_##.jpg
where YYYYMMDD is the date and ## is the number 01-10. This will generate the past 30 days as YYYYMMDD:
seq 30 | parallel date -d '``today -{} days''' +%Y%m%d
Based on this we can let GNU parallel generate 10 wgets per day:
the above | parallel -I {o} seq -w 10 ``|'' parallel wget http://www.example.com/path/to/{o}_{}.jpg
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.
tar xvf foo.tgz | perl -ne 'print $l;$l=$_;END{print $l}' | parallel echo
The Perl one-liner is needed to avoid race condition.
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:
cat list | parallel do_something | process_output
If the processing requires more steps the for-loop like this:
(for x in `cat list` ; do no_extension=${x%.*}; do_something $x scale $no_extension.jpg do_step2 <$x $no_extension done) | process_output
and while-loops like this:
cat list | (while read x ; do no_extension=${x%.*}; do_something $x scale $no_extension.jpg do_step2 <$x $no_extension done) | process_output
can be written like this:
cat list | parallel ``do_something {} scale {.}.jpg ; do_step2 <{} {.}'' | process_output
When running jobs that output data, you often do not want the output of multiple jobs to run together. GNU parallel defaults to grouping the output of each job, so the output is printed when the job finishes. If you want the output to be printed while the job is running you can use -u.
Compare the output of:
parallel traceroute ::: foss.org.my debian.org freenetproject.org
to the output of:
parallel -u traceroute ::: foss.org.my debian.org freenetproject.org
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. -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:
cat textfile | parallel -k echo {} append_string
If you remove -k some of the lines may come out in the wrong order.
Another example is traceroute:
parallel traceroute ::: foss.org.my debian.org freenetproject.org
will give traceroute of foss.org.my, debian.org and freenetproject.org, but it will be sorted according to which job completed first.
To keep the order the same as input run:
parallel -k traceroute ::: foss.org.my debian.org freenetproject.org
This will make sure the traceroute to foss.org.my will be printed 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 curl:
curl -r 10000000-19999999 http://example.com/the/big/file > file.part
To download a 1 GB file we need 100 10MB chunks downloaded and combined in the correct order.
seq 0 99 | parallel -k curl -r \ {}0000000-{}9999999 http://example.com/the/big/file > file
grep -r greps recursively through directories. On multicore CPUs GNU parallel can often speed this up.
find . -type f | parallel -k -j150% -n 1000 -m grep -H -n STRING {}
This will run 1.5 job per core, and give 1000 arguments to grep.
To grep a big file in parallel use --pipe:
cat bigfile | parallel --pipe grep foo
Depending on your disks and CPUs it may be faster to read larger blocks:
cat bigfile | parallel --pipe --block 10M grep foo
To run commands on a remote computer SSH needs to be set up and you must be able to login without entering a password (ssh-agent may be handy).
To run echo on server.example.com:
seq 10 | parallel --sshlogin server.example.com echo
To run commands on more than one remote computer run:
seq 10 | parallel --sshlogin server.example.com,server2.example.net echo
Or:
seq 10 | parallel --sshlogin server.example.com \ --sshlogin server2.example.net echo
If the login username is foo on server2.example.net use:
seq 10 | parallel --sshlogin server.example.com \ --sshlogin foo@server2.example.net echo
To distribute the commands to a list of computers, make a file mycomputers with all the computers:
server.example.com foo@server2.example.com server3.example.com
Then run:
seq 10 | parallel --sshloginfile mycomputers echo
To include the local computer add the special sshlogin ':' to the list:
server.example.com foo@server2.example.com server3.example.com :
GNU parallel will try to determine the number of CPU cores on each 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.
If the number of CPU cores on the remote computers is not identified correctly the number of CPU cores can be added in front. Here the computer has 8 CPU cores.
seq 10 | parallel --sshlogin 8/server.example.com echo
To recompress gzipped files with bzip2 using a remote computer run:
find logs/ -name '*.gz' | \ parallel --sshlogin server.example.com \ --transfer "zcat {} | bzip2 -9 >{.}.bz2"
This will list the .gz-files in the logs directory and all directories below. Then it will transfer the files to server.example.com to the corresponding directory in $HOME/logs. On server.example.com the file will be recompressed using zcat and bzip2 resulting in the corresponding file with .gz replaced with .bz2.
If you want the resulting bz2-file to be transferred back to the local computer add --return {.}.bz2:
find logs/ -name '*.gz' | \ parallel --sshlogin server.example.com \ --transfer --return {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
After the recompressing is done the .bz2-file is transferred back to the local computer and put next to the original .gz-file.
If you want to delete the transferred files on the remote computer add --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"
If you want run on several computers add the computers to --sshlogin either using ',' or multiple --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 --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 --transfer, --return and --cleanup are used together. They can be shortened to --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 mycomputers containing the list of computers it becomes:
find logs/ -name '*.gz' | parallel --sshloginfile mycomputers \ --trc {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
If the file ~/.parallel/sshloginfile contains the list of computers the special short hand -S .. can be used:
find logs/ -name '*.gz' | parallel -S .. \ --trc {.}.bz2 "zcat {} | bzip2 -9 >{.}.bz2"
Convert *.mp3 to *.ogg running one process per CPU core on local computer and server2:
parallel --trc {.}.ogg -S server2,: \ 'mpg321 -w - {} | oggenc -q0 - -o {.}.ogg' ::: *.mp3
Copy files like foo.es.ext to foo.ext:
ls *.es.* | perl -pe 'print; s/\.es//' | parallel -N2 cp {1} {2}
The perl command spits out 2 lines for each input. GNU parallel takes 2 inputs (using -N2) and replaces {1} and {2} with the inputs.
Print the number on the opposing sides of a six sided die:
parallel -a <(seq 6) -a <(seq 6 -1 1) echo
Convert files from all subdirs to PNG-files with consecutive numbers (useful for making input PNG's for ffmpeg):
parallel -a <(find . -type f | sort) -a <(seq $(find . -type f|wc -l)) convert {1} {2}.png
Alternative version:
find . -type f | sort | parallel convert {} \$PARALLEL_SEQ.png
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:
parallel -a table_file.tsv --colsep '\t' cmd -o {2} -i {1}
Note: The default for GNU parallel is to remove the spaces around the columns. To keep the spaces:
parallel -a table_file.tsv --trim n --colsep '\t' cmd -o {2} -i {1}
If you want to run the same command with the same arguments 10 times in parallel you can do:
seq 10 | parallel -n0 my_command my_args
GNU parallel can work similar to 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 wget http://status-server/status.cgi?ip=10.0.0.1 ping -c 1 10.0.0.2 wget http://status-server/status.cgi?ip=10.0.0.2 ... ping -c 1 10.0.0.255 wget http://status-server/status.cgi?ip=10.0.0.255
To run 100 processes simultaneously do:
parallel -j 100 < jobs_to_run
As there is not a command the jobs will be evaluated by the shell.
To process a big file or some output you can use --pipe to split up the data into blocks and pipe the blocks into the processing program.
If the program is gzip -9 you can do:
cat bigfile | parallel --pipe --recend '' -k gzip -9 >bigfile.gz
This will split bigfile into blocks of 1 MB and pass that to gzip -9 in parallel. One gzip will be run per CPU core. The output of gzip -9 will be kept in order and saved to bigfile.gz
gzip works fine if the output is appended, but some processing does not work like that - for example sorting. For this GNU parallel can put the output of each command into a file. This will sort a big file in parallel:
cat bigfile | parallel --pipe --files sort | parallel -Xj1 sort -m {} ';' rm {} >bigfile.sort
Here bigfile is split into blocks of around 1MB, each block ending in '\n' (which is the default for --recend). Each block is passed to sort and the output from sort is saved into files. These files are passed to the second parallel that runs sort -m on the files before it removes the files. The output is saved to bigfile.sort.
The command sem is an alias for 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 sem will wait for one of these to complete before starting another command. sem --wait will wait for all jobs to complete.
Run 10 jobs concurrently in the background:
for i in `ls *.log` ; do 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 myfile and prepends the file with lines with the numbers 1 to 3.
seq 3 | parallel sem sed -i -e 'i{}' myfile
As 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:
seq 3 | parallel sem --id mymutex sed -i -e 'i{}' myfile
You can use GNU Parallel to start interactive programs like emacs or vi:
cat filelist | parallel -T -X emacs
cat filelist | parallel -T -X vi
If there are more files than will fit on a single command line, the editor will be started again with the remaining files.
GNU 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 parallel read from that continuously. As GNU parallel will stop at end of file we use tail to continue reading:
echo >jobqueue; tail -f jobqueue | parallel
To submit your jobs to the queue:
echo my_command my_arg >> jobqueue
You can of course use -S to distribute the jobs to remote computers:
echo >jobqueue; tail -f jobqueue | parallel -S ..
There are a two small issues when using GNU parallel as queue system/batch manager:
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 inotifywait is called on other platforms file a bug report):
inotifywait -q -m -r -e CLOSE_WRITE --format %w%f my_dir | parallel -u echo
This will run the command echo on each file put into my_dir or subdirs of my_dir.
The -u is needed because of a small bug in GNU parallel. If that proves to be a problem, file a bug report.
You can of course use -S to distribute the jobs to remote computers:
inotifywait -q -m -r -e CLOSE_WRITE --format %w%f my_dir | parallel -S .. -u echo
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.
GNU parallel is very liberal in quoting. You only need to quote characters that have special meaning in shell:
( ) $ ` ' `` < > ; | \
and depending on context these needs to be quoted, too:
* ~ & # ! ? space * {
Therefore most people will never need more quoting than putting '\' in front of the special characters.
However, when you want to use a shell variable you need to quote the $-sign. Here is an example using $PARALLEL_SEQ. This variable is set by GNU parallel itself, so the evaluation of the $ must be done by the sub shell started by GNU parallel:
seq 10 | parallel -N2 echo seq:\$PARALLEL_SEQ arg1:{1} arg2:{2}
If the variable is set before GNU parallel starts you can do this:
VAR=this_is_set_before_starting
echo test | parallel echo {} $VAR
Prints: test this_is_set_before_starting
It is a little more tricky if the variable contains more than one space in a row:
VAR=``two spaces between each word''
echo test | parallel echo {} \'``$VAR''\'
Prints: test two spaces between each word
If the variable should not be evaluated by the shell starting GNU parallel but be evaluated by the sub shell started by GNU parallel, then you need to quote it:
echo test | parallel VAR=this_is_set_after_starting \; echo {} \$VAR
Prints: test this_is_set_after_starting
It is a little more tricky if the variable contains space:
echo test | parallel VAR='``two spaces between each word''' echo {} \'``$VAR''\'
Prints: test two spaces between each word
$$ is the shell variable containing the process id of the shell. This will print the process id of the shell running GNU parallel:
seq 10 | parallel echo $$
And this will print the process ids of the sub shells started by GNU parallel.
seq 10 | parallel echo \$\$
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 parallel and the sub shell:
echo test | parallel echo {} \\\$VAR
Prints: test $VAR
GNU parallel can protect against evaluation by the sub shell by using -q:
echo test | parallel -q echo {} \$VAR
Prints: test $VAR
This is particularly useful if you have lots of quoting. If you want to run a perl script like this:
perl -ne '/^\S+\s+\S+$/ and print $ARGV,``\n''' file
It needs to be quoted like this:
ls | parallel perl -ne '/^\\S+\\s+\\S+\$/\ and\ print\ \$ARGV,\``\\n\'''
Notice how spaces, \'s, ``'s, and $'s need to be quoted. GNU parallel can do the quoting by using option -q:
ls | parallel -q perl -ne '/^\S+\s+\S+$/ and print $ARGV,``\n'''
However, this means you cannot make the sub shell interpret special characters. For example because of -q this WILL NOT WORK:
ls *.gz | parallel -q ``zcat {} >{.}''
ls *.gz | parallel -q ``zcat {} | bzip2 >{.}.bz2''
because > and | need to be interpreted by the sub shell.
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 -q.
If you are using bash process substitution like <(cat foo) then you may try -q and prepending command with bash -c:
ls | parallel -q bash -c 'wc -c <(echo {})'
Or for substituting output:
ls | parallel -q bash -c 'tar c {} | tee >(gzip >{}.tar.gz) | bzip2 >{}.tar.bz2'
Conclusion: To avoid dealing with the quoting problems it may be easier just to write a small script and have GNU parallel call that script.
If you want a list of the jobs currently running you can run:
killall -USR1 parallel
GNU parallel will then print the currently running jobs on STDERR.
If you regret starting a lot of jobs you can simply break GNU parallel, but if you want to make sure you do not have halfcompleted jobs you should send the signal SIGTERM to GNU parallel:
killall -TERM parallel
This will tell GNU parallel to not start any new jobs, but wait until the currently running jobs are finished before exiting.
Example: If each of the jobs tests a solution and one of jobs finds the solution the job can tell GNU parallel not to start more jobs by: kill -TERM $PARALLEL_PID. This only works on the local computer.
Example:
seq 10 | parallel -N2 echo seq:'$'PARALLEL_SEQ arg1:{1} arg2:{2}
Example:
cat list | parallel -j1 -k -v ls
can be written as:
cat list | PARALLEL=``-kvj1'' parallel ls
cat list | parallel -j1 -k -v -S``myssh user@server'' ls
can be written as:
cat list | PARALLEL='-kvj1 -S myssh\ user@server' parallel echo
Notice the \ in the middle is needed because 'myssh' and 'user@server' must be one argument.
The file ~/.parallel/config (formerly known as .parallelrc) will be read if it exists. Lines starting with '#' will be ignored. It can be formatted like the environment variable $PARALLEL, but it is often easier to simply put each option on its own line.
Options on the command line takes precedence over the environment variable $PARALLEL which takes precedence over the file ~/.parallel/config.
If --profile set, GNU parallel will read the profile from that file instead of ~/.parallel/config.
Example: Profile for running every command with -j-1 and nice
echo -j-1 nice > ~/.parallel/nice_profile parallel -J nice_profile bzip2 -9 ::: *
Example: Profile for running a perl script before every command:
echo "perl -e '\$a=\$\$; print \$a,\" \",'\$PARALLEL_SEQ',\" \";';" > ~/.parallel/pre_perl parallel -J pre_perl echo ::: *
Note how the $ and `` need to be quoted using \.
Example: Profile for running distributed jobs with nice on the remote computers:
echo -S .. nice > ~/.parallel/dist parallel -J dist --trc {.}.bz2 bzip2 -9 ::: *
If --halt-on-error 0 or not specified:
If --halt-on-error 1 or 2: Exit status of the failing job.
There are a lot programs with some of the functionality of GNU parallel. GNU parallel strives to include the best of the functionality without sacrifying ease of use.
The following features are in some of the comparable tools:
Inputs I1. Arguments can be read from stdin I2. Arguments can be read from a file I3. Arguments can be read from multiple files I4. Arguments can be read from command line I5. Arguments can be read from a table I6. Arguments can be read from the same file using #! (shebang) I7. Line oriented input as default (Quoting of special chars not needed)
Manipulation of input M1. Composed command M2. Multiple arguments can fill up an execution line M3. Arguments can be put anywhere in the execution line M4. Multiple arguments can be put anywhere in the execution line M5. Arguments can be replaced with context M6. Input can be treated as complete execution line
Outputs O1. Grouping output so output from different jobs do not mix O2. Send stderr to stderr O3. Send stdout to stdout O4. Order of output can be same as order of input O5. Stdout only contains stdout from the command O6. Stderr only contains stdout from the command
Execution E1. Running jobs in parallel E2. List running jobs E3. Finish running jobs, but do not start new jobs E4. Number of running jobs can depend on number of cpus E5. Finish running jobs, but do not start new jobs after first failure E6. Number of running jobs can be adjusted while running
Remote execution R1. Jobs can be run on remote computers R2. Basefiles can be transferred R3. Argument files can be transferred R4. Result files can be transferred R5. Cleanup of transferred files R6. No config files needed R7. Do not run more than SSHD's MaxStartup can handle R8. Configurable SSH command R9. Retry if connection breaks occationally
Semaphore S1. Possibility to work as a mutex S2. Possibility to work as a counting semaphore
Legend - = no x = not applicable ID = yes
As every new version of the programs are not tested the table may be outdated. Please file a bug-report if you find errors (See REPORTING BUGS).
parallel: I1 I2 I3 I4 I5 I6 I7 M1 M2 M3 M4 M5 M6 O1 O2 O3 O4 O5 O6 E1 E2 E3 E4 E5 E6 R1 R2 R3 R4 R5 R6 R7 R8 R9 S1 S2
xargs: I1 I2 - - - - - - M2 M3 - - - - O2 O3 - O5 O6 E1 - - - - - - - - - - x - - - - -
find -exec: - - - x - x - - M2 M3 - - - - - O2 O3 O4 O5 O6 - - - - - - - - - - - - - - - - x x
make -j: - - - - - - - - - - - - - O1 O2 O3 - x O6 E1 - - - E5 - - - - - - - - - - - -
ppss: I1 I2 - - - - I7 M1 - M3 - - M6 O1 - - x - - E1 E2 ?E3 E4 - - R1 R2 R3 R4 - - ?R7 ? ? - -
pexec: I1 I2 - I4 I5 - - M1 - M3 - - M6 O1 O2 O3 - O5 O6 E1 - - E4 - E6 R1 - - - - R6 - - - S1 -
xjobs: TODO - Please file a bug-report if you know what features xjobs supports (See REPORTING BUGS).
prll: TODO - Please file a bug-report if you know what features prll supports (See REPORTING BUGS).
dxargs: TODO - Please file a bug-report if you know what features dxargs supports (See REPORTING BUGS).
mdm/middelman: TODO - Please file a bug-report if you know what features mdm/middelman supports (See REPORTING BUGS).
xapply: TODO - Please file a bug-report if you know what features xapply supports (See REPORTING BUGS).
paexec: TODO - Please file a bug-report if you know what features paexec supports (See REPORTING BUGS).
ClusterSSH: TODO - Please file a bug-report if you know what features ClusterSSH supports (See REPORTING BUGS).
xargs offer some of the same possibilites as GNU parallel.
xargs deals badly with special characters (such as space, ' and ``). To see the problem try this:
touch important_file touch 'not important_file' ls not* | xargs rm mkdir -p "My brother's 12\" records" ls | xargs rmdir
You can specify -0 or -d ``\n'', but many input generators are not optimized for using NUL as separator but are optimized for newline as separator. E.g head, tail, awk, ls, echo, sed, tar -v, perl (-0 and \0 instead of \n), locate (requires using -0), find (requires using -print0), grep (requires user to use -z or -Z), sort (requires using -z).
So GNU parallel's newline separation can be emulated with:
cat | xargs -d ``\n'' -n1 command
xargs can run a given number of jobs in parallel, but has no support for running number-of-cpu-cores jobs in parallel.
xargs has no support for grouping the output, therefore output may run together, e.g. the first half of a line is from one process and the last half of the line is from another process. The example Parallel grep cannot be done reliably with xargs because of this. To see this in action try:
parallel perl -e '\$a=\"1{}\"x10000000\;print\ \$a,\"\\n\"' '>' {} ::: a b c d e f ls -l a b c d e f parallel -kP4 -n1 grep 1 > out.par ::: a b c d e f echo a b c d e f | xargs -P4 -n1 grep 1 > out.xargs-unbuf echo a b c d e f | xargs -P4 -n1 grep --line-buffered 1 > out.xargs-linebuf echo a b c d e f | xargs -n1 grep --line-buffered 1 > out.xargs-serial ls -l out* md5sum out*
xargs has no support for keeping the order of the output, therefore if running jobs in parallel using xargs the output of the second job cannot be postponed till the first job is done.
xargs has no support for running jobs on remote computers.
xargs has no support for context replace, so you will have to create the arguments.
If you use a replace string in xargs (-I) you can not force xargs to use more than one argument.
Quoting in xargs works like -q in GNU parallel. This means composed commands and redirection require using bash -c.
ls | parallel ``wc {} > {}.wc''
becomes (assuming you have 8 cores)
ls | xargs -d ``\n'' -P8 -I {} bash -c ``wc {} > {}.wc''
and
ls | parallel ``echo {}; ls {}|wc''
becomes (assuming you have 8 cores)
ls | xargs -d ``\n'' -P8 -I {} bash -c ``echo {}; ls {}|wc''
find -exec offer some of the same possibilites as GNU parallel.
find -exec only works on files. So processing other input (such as hosts or URLs) will require creating these inputs as files. find -exec has no support for running commands in parallel.
make -j can run jobs in parallel, but requires a crafted Makefile to do this. That results in extra quoting to get filename containing newline to work correctly.
make -j has no support for grouping the output, therefore output may run together, e.g. the first half of a line is from one process and the last half of the line is from another process. The example Parallel grep cannot be done reliably with make -j because of this.
(Very early versions of GNU parallel were coincidently implemented using make -j).
ppss is also a tool for running jobs in parallel.
The output of ppss is status information and thus not useful for using as input for another command. The output from the jobs are put into files.
The argument replace string ($ITEM) cannot be changed. Arguments must be quoted - thus arguments containing special characters (space '``&!*) may cause problems. More than one argument is not supported. File names containing newlines are not processed correctly. When reading input from a file null cannot be used as a terminator. ppss needs to read the whole input file before starting any jobs.
Output and status information is stored in ppss_dir and thus requires cleanup when completed. If the dir is not removed before running ppss again it may cause nothing to happen as ppss thinks the task is already done. GNU parallel will normally not need cleaning up if running locally and will only need cleaning up if stopped abnormally and running remote (--cleanup may not complete if stopped abnormally). The example Parallel grep would require extra postprocessing if written using ppss.
For remote systems PPSS requires 3 steps: config, deploy, and start. GNU parallel only requires one step.
Here are the examples from ppss's manual page with the equivalent using GNU parallel:
1 ./ppss.sh standalone -d /path/to/files -c 'gzip '
1 find /path/to/files -type f | parallel gzip
2 ./ppss.sh standalone -d /path/to/files -c 'cp ``$ITEM'' /destination/dir '
2 find /path/to/files -type f | parallel cp {} /destination/dir
3 ./ppss.sh standalone -f list-of-urls.txt -c 'wget -q '
3 parallel -a list-of-urls.txt wget -q
4 ./ppss.sh standalone -f list-of-urls.txt -c 'wget -q ``$ITEM'''
4 parallel -a list-of-urls.txt wget -q {}
5 ./ppss config -C config.cfg -c 'encode.sh ' -d /source/dir -m 192.168.1.100 -u ppss -k ppss-key.key -S ./encode.sh -n nodes.txt -o /some/output/dir --upload --download ; ./ppss deploy -C config.cfg ; ./ppss start -C config
5 # parallel does not use configs. If you want a different username put it in nodes.txt: user@hostname
5 find source/dir -type f | parallel --sshloginfile nodes.txt --trc {.}.mp3 lame -a {} -o {.}.mp3 --preset standard --quiet
6 ./ppss stop -C config.cfg
6 killall -TERM parallel
7 ./ppss pause -C config.cfg
7 Press: CTRL-Z or killall -SIGTSTP parallel
8 ./ppss continue -C config.cfg
8 Enter: fg or killall -SIGCONT parallel
9 ./ppss.sh status -C config.cfg
9 killall -SIGUSR2 parallel
pexec is also a tool for running jobs in parallel.
Here are the examples from pexec's info page with the equivalent using GNU parallel:
1 pexec -o sqrt-%s.dat -p ``$(seq 10)'' -e NUM -n 4 -c -- \ 'echo ``scale=10000;sqrt($NUM)'' | bc'
1 seq 10 | parallel -j4 'echo ``scale=10000;sqrt({})'' | bc > sqrt-{}.dat'
2 pexec -p ``$(ls myfiles*.ext)'' -i %s -o %s.sort -- sort
2 ls myfiles*.ext | parallel sort {} ``>{}.sort''
3 pexec -f image.list -n auto -e B -u star.log -c -- \ 'fistar $B.fits -f 100 -F id,x,y,flux -o $B.star'
3 parallel -a image.list \ 'fistar {}.fits -f 100 -F id,x,y,flux -o {}.star' 2>star.log
4 pexec -r *.png -e IMG -c -o - -- \ 'convert $IMG ${IMG%.png}.jpeg ; ``echo $IMG: done'''
4 ls *.png | parallel 'convert {} {.}.jpeg; echo {}: done'
5 pexec -r *.png -i %s -o %s.jpg -c 'pngtopnm | pnmtojpeg'
5 ls *.png | parallel 'pngtopnm < {} | pnmtojpeg > {}.jpg'
6 for p in *.png ; do echo ${p%.png} ; done | \ pexec -f - -i %s.png -o %s.jpg -c 'pngtopnm | pnmtojpeg'
6 ls *.png | parallel 'pngtopnm < {} | pnmtojpeg > {.}.jpg'
7 LIST=$(for p in *.png ; do echo ${p%.png} ; done) pexec -r $LIST -i %s.png -o %s.jpg -c 'pngtopnm | pnmtojpeg'
7 ls *.png | parallel 'pngtopnm < {} | pnmtojpeg > {.}.jpg'
8 pexec -n 8 -r *.jpg -y unix -e IMG -c \ 'pexec -j -m blockread -d $IMG | \ jpegtopnm | pnmscale 0.5 | pnmtojpeg | \ pexec -j -m blockwrite -s th_$IMG'
8 Combining GNU parallel and GNU sem.
8 ls *jpg | parallel -j8 'sem --id blockread cat {} | jpegtopnm |' \ 'pnmscale 0.5 | pnmtojpeg | sem --id blockwrite cat > th_{}'
8 If reading and writing is done to the same disk, this may be faster as only one process will be either reading or writing:
8 ls *jpg | parallel -j8 'sem --id diskio cat {} | jpegtopnm |' \ 'pnmscale 0.5 | pnmtojpeg | sem --id diskio cat > th_{}'
xjobs is also a tool for running jobs in parallel. It only supports running jobs on your local computer.
xjobs deals badly with special characters just like xargs. See the section DIFFERENCES BETWEEN xargs AND GNU Parallel.
Here are the examples from xjobs's man page with the equivalent using GNU parallel:
1 ls -1 *.zip | xjobs unzip
1 ls *.zip | parallel unzip
2 ls -1 *.zip | xjobs -n unzip
2 ls *.zip | parallel unzip >/dev/null
3 find . -name '*.bak' | xjobs gzip
3 find . -name '*.bak' | parallel gzip
4 ls -1 *.jar | sed 's/\(.*\)/\1 > \1.idx/' | xjobs jar tf
4 ls *.jar | parallel jar tf {} '>' {}.idx
5 xjobs -s script
5 cat script | parallel
6 mkfifo /var/run/my_named_pipe; xjobs -s /var/run/my_named_pipe & echo unzip 1.zip >> /var/run/my_named_pipe; echo tar cf /backup/myhome.tar /home/me >> /var/run/my_named_pipe
6 mkfifo /var/run/my_named_pipe; cat /var/run/my_named_pipe | parallel & echo unzip 1.zip >> /var/run/my_named_pipe; echo tar cf /backup/myhome.tar /home/me >> /var/run/my_named_pipe
prll is also a tool for running jobs in parallel. It does not support running jobs on remote computers.
prll encourages using BASH aliases and BASH functions instead of scripts. GNU parallel will never support running aliases and functions (see why http://www.perlmonks.org/index.pl?node_id=484296). However, scripts or composed commands work just fine.
prll generates a lot of status information on STDERR which makes it harder to use the STDERR output of the job directly as input for another program.
Here is the example from prll's man page with the equivalent using GNU parallel:
prll -s 'mogrify -flip $1' *.jpg
parallel mogrify -flip ::: *.jpg
dxargs is also a tool for running jobs in parallel.
dxargs does not deal well with more simultaneous jobs than SSHD's MaxStartup. dxargs is only built for remote run jobs, but does not support transferring of files.
middleman(mdm)
is also a tool for running jobs in parallel.
Here are the shellscripts of http://mdm.berlios.de/usage.html ported to GNU parallel:
seq 19 | parallel buffon -o - | sort -n > result
cat files | parallel cmd
find dir -execdir sem cmd {} \;
xapply can run jobs in parallel on the local computer.
Here are the examples from xapply's man page with the equivalent using GNU parallel:
1 xapply '(cd %1 && make all)' */
1 parallel 'cd {} && make all' ::: */
2 xapply -f 'diff %1 ../version5/%1' manifest | more
2 parallel diff {} ../version5/{} < manifest | more
3 xapply -p/dev/null -f 'diff %1 %2' manifest1 checklist1
3 parallel diff {1} {2} :::: manifest1 checklist1
4 xapply 'indent' *.c
4 parallel indent ::: *.c
5 find ~ksb/bin -type f ! -perm -111 -print | xapply -f -v 'chmod a+x' -
5 find ~ksb/bin -type f ! -perm -111 -print | parallel -v chmod a+x
6 find */ -... | fmt 960 1024 | xapply -f -i /dev/tty 'vi' -
6 sh <(find */ -... | parallel -s 1024 echo vi)
6 find */ -... | parallel -s 1024 -Xuj1 vi
7 find ... | xapply -f -5 -i /dev/tty 'vi' - - - - -
7 sh <(find ... |parallel -n5 echo vi)
7 find ... |parallel -n5 -uj1 vi
8 xapply -fn ``'' /etc/passwd
8 parallel -k echo < /etc/passwd
9 tr ':' '\012' < /etc/passwd | xapply -7 -nf 'chown %1 %6' - - - - - - -
9 tr ':' '\012' < /etc/passwd | parallel -N7 chown {1} {6}
10 xapply '[ -d %1/RCS ] || echo %1' */
10 parallel '[ -d {}/RCS ] || echo {}' ::: */
11 xapply -f '[ -f %1 ] && echo %1' List | ...
11 parallel '[ -f {} ] && echo {}' < List | ...
paexec can run jobs in parallel on both the local and remote computers.
paexec requires commands to print a blank line as the last output. This means you will have to write a wrapper for most programs.
paexec has a job dependency facility so a job can depend on another job to be executed successfully. Sort of a poor-man's make.
Here are the examples from paexec's example catalog with the equivalent using GNU parallel:
../../paexec -s -l -c "`pwd`/1_div_X_cmd" -n +1 <<EOF [...] parallel echo {} '|' `pwd`/1_div_X_cmd <<EOF [...]
../../paexec -lp -c "`pwd`/all_substr_cmd" -n +3 <<EOF [...] parallel echo {} '|' `pwd`/all_substr_cmd <<EOF [...]
../../paexec -c "env CC=gcc CFLAGS=-O2 `pwd`/cc_wrapper_cmd" \ -n 'host1 host2' \ -t '/usr/bin/ssh -x' <<EOF [...] parallel echo {} '|' "env CC=gcc CFLAGS=-O2 `pwd`/cc_wrapper_cmd" \ -S host1,host2 <<EOF [...] # This is not exactly the same, but avoids the wrapper parallel gcc -O2 -c -o {.}.o {} \ -S host1,host2 <<EOF [...]
../../paexec -lp -c "`pwd`/toupper_cmd" -n +10 <<EOF [...] parallel echo {} '|' ./toupper_cmd <<EOF [...] # Without the wrapper: parallel echo {} '| awk {print\ toupper\(\$0\)}' <<EOF [...]
ClusterSSH solves a different problem than GNU parallel.
ClusterSSH runs the same command with the same arguments on a list of computers - one per computer. This is typically used for administrating several computers that are almost identical.
GNU parallel runs the same (or different) commands with different arguments in parallel possibly using remote computers to help computing. If more than one computer is listed in -S GNU parallel may only use one of these (e.g. if there are 8 jobs to be run and one computer has 8 cores).
GNU parallel can be used as a poor-man's version of ClusterSSH:
cat hostlist | parallel ssh {} do_stuff
Because of the way newline is quoted this will not work:
echo 1,2,3 | parallel -vkd, ``echo 'a{}b'''
However, these will all work:
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'''
GNU parallel is slow at starting up. Half of the startup time on the local computer is spent finding the maximal length of a command line. Setting -s will remove this part of the startup time.
When using multiple computers GNU parallel opens ssh connections to them to figure out how many connections can be used reliably simultaneously (Namely SSHD's MaxStartup). This test is done for each host in serial, so if your --sshloginfile contains many hosts it may be slow.
The current implementation of --nice is too pessimistic in the max allowed command length. It only uses a little more than half of what it could. This affects -X and -m. If this becomes a real problem for you file a bug-report.
If you get:
Can't exec ``command'': No such file or directory
or:
open3: exec of by command failed
it may be because command is not known, but it could also be because command is an alias or a function. GNU parallel will never support running aliases and functions (see why http://www.perlmonks.org/index.pl?node_id=484296), so change your alias or function to a script.
Report bugs to <bug-parallel@gnu.org> or https://savannah.gnu.org/bugs/?func=additem&group=parallel
Your bugreport should always include:
When using GNU Parallel for a publication please cite:
O. Tange (2011): GNU Parallel - The Command-Line Power Tool, ;login: The USENIX Magazine, February 2011:42-47.
Copyright (C) 2007-10-18 Ole Tange, http://ole.tange.dk
Copyright (C) 2008,2009,2010 Ole Tange, http://ole.tange.dk
Copyright (C) 2010,2011 Ole Tange, http://ole.tange.dk and Free Software Foundation, Inc.
Parts of the manual concerning xargs compatibility is inspired by the manual of xargs from GNU findutils 4.4.2.
Copyright (C) 2007,2008,2009,2010,2011 Free Software Foundation, Inc.
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/>.
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.
You are free:
Under the following conditions:
With the understanding that:
A copy of the full license is included in the file as cc-by-sa.txt.
GNU parallel uses Perl, and the Perl modules Getopt::Long, IPC::Open3, Symbol, IO::File, POSIX, and File::Temp. For remote usage it also uses rsync with ssh.
ssh(1), rsync(1), find(1), xargs(1), make(1), pexec(1), ppss(1), xjobs(1), prll(1), dxargs(1), mdm(1),