Created
November 13, 2017 19:50
-
-
Save daniel-thompson/bfe124d8e7374464924d4b86f35235b3 to your computer and use it in GitHub Desktop.
bash job server
This file contains 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
# `parallel <cmd...>` works similarly to `<cmd...> &` but limits the | |
# maximum job count to prevent over-zealous memory consumption when | |
# batch processing huge numbers of files. | |
parallel () { | |
while [ "$(jobs | wc -l)" -ge $((3 * $(nproc) / 2)) ] | |
do | |
wait -n | |
done | |
"$@" & | |
} | |
for f in $jpegs | |
do | |
parallel convert $f --resize ... | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment