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
|
|
|
|
|
|
|
`parallel gzip ::: {{file1}} {{file2}} {{file3}}`
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Read arguments from stdin, run 4 jobs at once:
|
2015-12-30 04:55:04 +00:00
|
|
|
|
|
|
|
`ls *.txt | parallel -j4 gzip`
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Convert JPG 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}}`
|
|
|
|
|
2016-01-07 17:31:27 +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}}`
|