MACOS run 3x commands terminal in parallel and single threaded

SHARE THIS NOW!

URL

illphated

Gemini_Generated_Image_t79rlet79rlet79r.jpeg

run_parallel_loop.sh

3X IN A ROW 1 by 1




#!/bin/bash

# Replace this with your actual command
COMMAND=”echo Running your command”

# Repeat 99 times
for i in {1..99}
do
echo “Round $i…”

# Run 3 commands in parallel
$COMMAND &
$COMMAND &
$COMMAND &

# Wait for all 3 to finish before the next round
wait
done

3x SAME TIME

#!/bin/bash

# Replace this with your actual command
COMMAND=”sleep 5″ # Example command (replace with yours)

# Run 99 loops
for i in {1..99}
do
echo “=== Round $i ===”

# Run 3 instances in the background
eval “$COMMAND” &
eval “$COMMAND” &
eval “$COMMAND” &

# Wait for all 3 to finish before looping again
wait
done

Email

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top