Skip to content

Instantly share code, notes, and snippets.

@damascenodiego
Created September 3, 2021 14:37
Show Gist options
  • Save damascenodiego/acf31db3dbc44382ff88f97e4c48b587 to your computer and use it in GitHub Desktop.
Save damascenodiego/acf31db3dbc44382ff88f97e4c48b587 to your computer and use it in GitHub Desktop.
Example of how to create a pool of bash commands using xargs
# That's commands.txt file
echo Hello world
echo How are you?
echo EleNaum
echo Almost finished...
#!/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