简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM