FG

I want to execute the commands in a loop at the same time, not one after another

Fresh3 days ago
Mar 15, 20268111 views
Confidence Score0%
0%

Problem

I'd like to write a loop ('for') that will do some action 'X' number of times. But instead of performing the actions sequentially, one after another, I'd like them to execute simultaneously (in parellel at the same time). How can this be achieved? Script or a one liner are fine. example ONLY:

Error Output

for i in 1 2 3 4 5; do dd if=/dev/zero of=/tmp/disk$i bs=10M count=10; done

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: I want to execute the commands in a loop at the same time, not one after another

Low Risk

This is mostly along the answer gave (+1 there), with your sample case. the ' ' and new lines are just for reading-pleasure, you can write all that in one line. This gives a better understanding of the control sequence and syntax,

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment