The magic of "&" in shell -- implementing multi-process concurrency

Source: Internet
Author: User
A simple dd script is written for testing, as follows #! /Bin/shfor (i1; I & lt; 5; I ++); do {ddif/mnt/ufstest/test $ I. when running tsof/dev/nullbs480K} done, dd can only read one file at the same time, which does not work for me. I wanted to implement more...

A simple dd script is written for testing.

#! /Bin/sh
For (I = 1; I <= 5; I ++); do
{
Dd if =/mnt/ufstest/test $ I. ts of =/dev/null bs = 480 K
}
Done
During execution, I found that dd can only read one file at the same time, not achieving my effect. I wanted to implement concurrent read performance measurement for multiple dd processes.

650) this. width = 650; "src =" http://up.2cto.com/2011/0930/20110930095733665.png "style =" border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; margin: 0px; vertical-align: top; padding-top: 0px; border-right-width: 0px "title =" image "/>

 

Google Now, you only need to add "&" to achieve multi-concurrency.

#! /Bin/sh
For (I = 1; I <= 5; I ++); do
{
Dd if =/mnt/ufstest/test $ I. ts of =/dev/null bs = 480 K&
}
Done

Results:

650) this. width = 650; "src =" http://up.2cto.com/2011/0930/20110930095734732.png "style =" border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; margin: 0px; vertical-align: top; padding-top: 0px; border-right-width: 0px "title =" image "/>

Author: "star & storage"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.