Created
September 3, 2021 14:37
-
-
Save damascenodiego/acf31db3dbc44382ff88f97e4c48b587 to your computer and use it in GitHub Desktop.
Example of how to create a pool of bash commands using xargs
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
# That's commands.txt file | |
echo Hello world | |
echo How are you? | |
echo EleNaum | |
echo Almost finished... |
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
#!/bin/sh | |
# Sources: | |
# - https://stackoverflow.com/a/59652795 | |
# - http://coldattic.info/post/7/ | |
MAX_PROCS=7 | |
TIMEOUT=60m | |
cat commands.txt | xargs -I CMD --max-procs=$MAX_PROCS timeout $TIMEOUT bash -c "CMD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment