twigg
twigg

Reputation: 3993

BASH Loop run commands simultaneously

I have created a script which reads the number of HDD's attached then runs a speed test on them using HDDParm

for i in `seq -s' ' $from $hddcount`
do
    # read and cache read speed test
    sudo hdparm -tT ${hd[$i]} >> /var/www/HDD_Test/Logs/Current/Bay$i/`basename ${hd[$i]}`_speed_test.txt
done

This works fine but it runs the test one by one which is ok for the speed test to get a true figure, but I now want to run a short SMART check using smartctl.

I want it to run simultaneously on all the HDD's attached, not one at a time. Anyone have any ideas or pointers on how to do this? Would it be a simple case of running them in the background with the & notation?

Upvotes: 0

Views: 1308

Answers (1)

Brian Agnew
Brian Agnew

Reputation: 272237

Why not just put it in the background using & ? See this SO question for more info.

Upvotes: 2

Related Questions