2016-09-22 08:03:38 +01:00
|
|
|
# parallel
|
2015-12-30 04:55:04 +00:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Run commands on multiple CPU cores.
|
2019-06-04 10:00:18 +01:00
|
|
|
> More information: <https://www.gnu.org/software/parallel>.
|
2015-12-30 04:55:04 +00:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Gzip several files at once, using all cores:
|
2015-12-30 04:55:04 +00:00
|
|
|
|
2024-01-31 03:55:19 +00:00
|
|
|
`parallel gzip ::: {{path/to/file1 path/to/file2 ...}}`
|
2015-12-30 04:55:04 +00:00
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Read arguments from `stdin`, run 4 jobs at once:
|
2015-12-30 04:55:04 +00:00
|
|
|
|
|
|
|
`ls *.txt | parallel -j4 gzip`
|
|
|
|
|
2024-03-14 05:01:06 +00:00
|
|
|
- Convert JPEG images to PNG using replacement strings:
|
2015-12-30 04:55:04 +00:00
|
|
|
|
|
|
|
`parallel convert {} {.}.png ::: *.jpg`
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Parallel xargs, cram as many args as possible onto one command:
|
2015-12-30 04:55:04 +00:00
|
|
|
|
|
|
|
`{{args}} | parallel -X {{command}}`
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Break `stdin` into ~1M blocks, feed each block to `stdin` of new command:
|
2015-12-30 04:55:04 +00:00
|
|
|
|
2016-07-22 21:24:06 +01:00
|
|
|
`cat {{big_file.txt}} | parallel --pipe --block 1M {{command}}`
|
2015-12-30 04:55:04 +00:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Run on multiple machines via SSH:
|
2015-12-30 04:55:04 +00:00
|
|
|
|
|
|
|
`parallel -S {{machine1}},{{machine2}} {{command}} ::: {{arg1}} {{arg2}}`
|
2024-02-08 07:03:52 +00:00
|
|
|
|
|
|
|
- Download 4 files simultaneously from a text file containing links showing progress:
|
|
|
|
|
|
|
|
`parallel -j4 --bar --eta wget -q {} :::: {{path/to/links.txt}}`
|
|
|
|
|
|
|
|
- Print the jobs which `parallel` is running in `stderr`:
|
|
|
|
|
2024-02-08 13:45:33 +00:00
|
|
|
`parallel -t {{command}} ::: {{args}}`
|