Last active
February 11, 2024 01:24
-
-
Save atheiman/dda0a9bac4d1dbe04648617d86d47b56 to your computer and use it in GitHub Desktop.
GNU Parallel install and usage notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install GNU parallel in a CentOS-based docker container (e.g. for CI/CD) | |
# install needed dependencies | |
yum install -q -y bzip2 tar make perl | |
# download source | |
curl -s -L -o /tmp/parallel.tar.bz2 https://ftpmirror.gnu.org/parallel/parallel-latest.tar.bz2 | |
# extract source | |
tar -C /tmp -xjf /tmp/parallel.tar.bz2 | |
# navigate into extracted source | |
cd /tmp/parallel-* | |
# build and install | |
./configure && make && make install | |
# return to previous directory | |
cd - | |
# verify version of parallel installed | |
parallel --version | head -1 | |
# get past annoying parallel citation prompt | |
echo 'will cite' | parallel --citation &> /dev/null || true | |
# example simple usage | |
parallel echo ::: a b c | |
# Run jobs in 5 parallel "job slots", different color for the prefix of each job's output. Unique colors will only be | |
# used up to 8 parallel job slots (there are usually only 8 possible terminal colors). | |
# {%} prints the jobs slot number in the "tagstring" | |
# {} prints the job input, it can be modified with other replacement strings (e.g. to remove the path from a filename) | |
# https://www.gnu.org/software/parallel/parallel_tutorial.html#the-7-predefined-replacement-strings | |
parallel -j 5 --tagstring '\033[3{%}m[Job Slot {%}] [{}]\033[0m' --linebuffer head -3 ::: $(find -L /etc -type f | head -8) | |
# Run the same command 25 times in batches of 5. Prints job number in tag string. | |
seq 1 25 | parallel --tagstring '(Job Number {#})' -j 5 --linebuffer -n 0 'sleep 3 && openssl rand -hex 16' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment