Para¶
Para is a command-line utility that runs jobs in parallel.
It is simpler, more lightweight, and more portable than Concurrently, GNU Parallel, or rust-parallel. It’s fast, too.
Para comprises a single source file, is written in C99, only uses the
Unix standard library, and compiles with -Wall -Wextra -Werror
.
It should work out-of-the-box on almost every Unix-like system and be
easy to integrate into C-based projects.
Examples¶
Run echo foo and echo bar in parallel:
$ para 'echo foo' 'echo bar'
bar
foo
Compose commands from arguments:
$ para -k 'echo {}' foo bar baz
foo
bar
baz
Add FOO=bar
and BAZ=qux
to the job environment:
$ para FOO=bar BAZ=qux 'sh -c "echo $FOO"' 'sh -c "echo $BAZ"'
bar
qux
Comparison¶
The GNU parallel documentation features an in-depth comparison of tools that run commands in parallel. This is how Para rates according to their comparison matrix:
ID |
Description |
Supported |
---|---|---|
I1 |
Arguments can be read from standard input. |
With xargs(1) |
I2 |
Arguments can be read from a file. |
With xargs(1) |
I3 |
Arguments can be read from multiple files. |
– “ – and cat(1) |
I4 |
Arguments can be read from command line. |
Yes |
I5 |
Arguments can be read from a table. |
With awk(1) |
I6 |
Arguments can be read from the same file using |
No |
I7 |
Line oriented input as default. |
n/a |
M1 |
Composed commands. |
Yes |
M2 |
Multiple arguments can fill up an execution line. |
Yes |
M3 |
Arguments can be put anywhere in execution line. |
Yes |
M4 |
Multiple arguments can be put anywhere in execution line. |
Yes |
M5 |
Arguments can be replaced with context. |
No |
M6 |
Input can be treated as the complete command line. |
With xargs(1) |
O1 |
Grouping output so output from different jobs does not mix. |
No |
O2 |
Send standard error to standard error. |
Yes |
O3 |
Send standard output to standard output. |
Yes |
O4 |
Order of output can be same as order of input. |
No |
O5 |
Standard output only contains standard output from command. |
Yes |
O6 |
Standard error only contains standard error from command. |
Yes |
O7 |
Buffering on disk. |
n/a |
O8 |
No temporary files left if killed. |
Yes |
O9 |
Test if disk runs full during run. |
n/a |
O10 |
Output of a line bigger than 4 GB. |
Probably [1] |
E1 |
Run jobs in parallel. |
Yes |
E2 |
List running jobs. |
Partly [2] |
E3 |
Finish running jobs, but do not start new ones. |
Yes |
E4 |
Number of running jobs can depend on number of CPUs. |
Yes |
E5 |
Finish running jobs, but do not start new ones after failure. |
Yes |
E6 |
Number of running jobs can be adjusted while running. |
No |
E7 |
Only spawn new jobs if load is less than a limit. |
Yes |
E8 |
Has non-zero exit value if any job has non-zero exit value. |
Yes |
E9 |
Jobs can be started without reading all input first. |
n/a |
R1 |
Jobs can be run on remote computers. |
No |
R2 |
Basefiles can be transferred. |
n/a |
R3 |
Argument files can be transferred. |
n/a |
R4 |
Result files can be transferred. |
n/a |
R5 |
Cleanup of transferred files. |
n/a |
R6 |
No config files needed. |
n/a |
R7 |
Do not run more commands than SSHD can handle. |
n/a |
R8 |
Configurable SSH command. |
n/a |
R9 |
Retry if connection breaks occasionally. |
n/a |
S1 |
Possibility to work as a mutex. |
No |
S2 |
Possibility to work as a counting semaphore. |
No |
GNU Parallel is the only tool that supports all of the above features. Para is designed to be simple and portable, not feature-rich. If you need to keep track of the output of individual jobs or distribute jobs over multiple machines, GNU Parallel is likely the best choice.