Skip to content

Instantly share code, notes, and snippets.

View beugley's full-sized avatar

Brian Eugley beugley

View GitHub Profile
@beugley
beugley / run_parallel.sh
Created February 1, 2022 16:07
Bash functions to run other commands in parallel with output serialized
#!/bin/bash
# Contains common functions that can be sourced by other bash scripts
function RunParallel
# Usage: Set the PROCESSES and CONCURRENCY variables and invoke RunParallel without parameters
# PROCESSES: An array of commands to execute
# CONCURRENCY: The number of commands to execute concurrently
# - Takes a list of processes in the PROCESSES variable, runs them in parallel, waits for
# each to complete, and then serializes their output (i.e. not interleaved).
# - If any process fails, then RunParallel will return a non-0 value.