Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Linux Shell Scripting multithreading     - Ubuntu 14.10 Apache installation and configuration (Server)

- Install the latest ATI / Nvidia graphics driver on Ubuntu (Linux)

- Install mono offline on CentOS (Server)

- How to upgrade to Ubuntu 14.04 Linux Kernel 4.4.1 LTS (Linux)

- Briefly explain the invasion of the four-level denial of service attack DoS Linux server (Linux)

- Four Methods of Self - Learning Linux (Linux)

- Install Jetty on CentOS / RHEL 6.X (Server)

- When Linux Detailed time zone and common function of time (Linux)

- Oracle view object space usage show_space (Database)

- JavaScript in null undefined summary (Linux)

- How to cool down your Ubuntu system (Linux)

- Mongo-connector integrated MongoD to achieve incremental Solr index (Server)

- ELKstack log analysis platform (Server)

- PLSQL often lose resolution process automatically disconnect the connection (Database)

- OpenSUSE / Linux network configuration (Linux)

- Linux environment RabbitMQ installation and monitoring of plug-in installation (Linux)

- How to manage your to-do list with the Go For It on Ubuntu (Linux)

- expdp reported ORA-39181 Export Processing Method (Database)

- Shell Common Command Summary (Programming)

- Construction Spark source and application development environment (Server)

 
         
  Linux Shell Scripting multithreading
     
  Add Date : 2018-11-21      
         
         
         
  In bash, we (&) multi-threaded through the background.

 for ((i = 1; i <= pairs; i ++))
 do
    mongo = "mongo_00 $ i"
    acmeair_web = "acmeair_web_00 $ i"
{
    docker run --name $ mongo -d -p $ port_m: 27017 mymongodb
    docker run -d -p $ port: 9080 --name $ acmeair_web --link $ {mongo}: mongo acmeair / web
} &
    ((Port ++))
    ((Port_m ++))
 done
 wait

We have added a {&} {} so that you can execute in the background, the above is equivalent to two pairs simultaneously performed, wait wait after they are executed.

-------------------------------------------------- ------------------------------

We are all of the above, the number of concurrent uncontrollable, following controllable.

tmp_fifofile = "/ tmp / $$. fifo"
mkfifo $ tmp_fifofile # Create a fifo file types
exec 6 < > $ tmp_fifofile # fifo will fd6 point type
rm $ tmp_fifofile

thread = 15 # the number of threads defined herein
for ((i = 0; i <$ thread; i ++)); do
echo
done> & 6 # fd6 in fact, it is placed in a carriage return $ thread

for ((i = 0; i <50; i ++)); do # 50 cycles
read -u6 # a read -u6 command execution time is subtracted from fd6 a carriage return, and then execute down
# Fd6 no carriage return when stopped here, the number of threads in order to achieve control
{
    {
        docker run ... mongodb
        docker run ... acmeair / web
    } && {
        echo "subprocess is finished"
    } || {
        echo "error"
    }
    echo> & # 6 after the end of the process when, again in fd6 add a carriage return, which make up that read -u6 minus
} &
done
wait # wait for all background child process ends

exec 6> & - # Close fd6

exit 01
     
         
         
         
  More:      
 
- Intel Graphics Installer 1.0.3 released, support for Ubuntu (Linux)
- Java multi-threaded communications pipeline flow (Programming)
- Talk about the Linux ABI compatibility Application (Linux)
- To change CentOS7 runlevel (Linux)
- CentOS 6.6 source compiler GCC upgrade to 4.8.2 (Linux)
- Zookeeper cluster deployment (Server)
- Ubuntu users how to install the latest Nvidia graphics drivers (Linux)
- Fedora && Arch Linux - the most romantic thing to happen now (Linux)
- Linux Network Programming - raw socket Example: sending a UDP packet (Programming)
- To install HDRMerge 0.4.3 under ubuntu (Linux)
- How to install MySQL on Linux Dock (Database)
- Linux source code analysis tool (Linux)
- Linux Basic Course: Install the software from source code (Linux)
- Using Vagrant to build multi-platform environment (Server)
- Ubuntu install perfectly handsome terminal Guake 0.8.1 (Linux)
- Fedora 22 installation and configuration optimization (Linux)
- Linux command line ten magic usage (Linux)
- Android screen rotation processing and ProgressDialog the best AsyncTask (Programming)
- Ubuntu root user profiles (Programming)
- MySQL error: ERROR 1175: You are using safe update mode solution (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.