Execute jobs in parallel from command line or files.
medium risk
GNU parallel runs jobs concurrently across CPU cores or remote hosts, replacing xargs -P with a more powerful and flexible interface. Supports progress bars, retry logic, input from files, and running across SSH hosts. Essential for bulk operations.
| Flag | Meaning |
|---|---|
-j --jobs | Number of parallel jobs (default: CPU count) |
--delay | Delay between job starts |
--retries | Retry failed jobs N times |
--progress | Show progress bar |
-S --ssh | Run jobs on remote hosts via SSH |
parallel -j 8 gzip ::: *.logCompress log files 8 at a time · explain & risk-check →cat urls.txt | parallel -j 10 curl -ODownload 10 URLs simultaneously · explain & risk-check →parallel -j 4 --progress kubectl delete pod ::: $(kubectl get pods -o name)Delete pods 4 at a time with progress · explain & risk-check →parallel --retries 3 'curl -f {}' ::: $(cat endpoints.txt)Test endpoints with retry on failure · explain & risk-check →Use `parallel --delay 0.1` when hitting APIs to avoid rate limiting — adds 100ms between job starts while still running many jobs concurrently.
Reference text is hand-written and may be incomplete — check man parallel for your version. Test destructive commands on a non-production system first.