Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Linux Shell Scripting multithreading     - Installation and management of Linux applications (Linux)

- Amazon EC2 server using Rsync + Inotify real-time synchronization (Server)

- Installation configuration CUDA under Ubuntu 14.04 (Linux)

- Linux / Unix: chroot command examples to explain (Linux)

- There is sort of a directed acyclic graph topology (Programming)

- for (int a: i) the use of the Java programming (Programming)

- Mybatis + binding Struts2: achieving user to insert and find (Programming)

- Google open source TCP team repaired the Linux kernel TCP flaw (Linux)

- php for Linux the MySQL extension module installation and configuration (Database)

- Redis application of Sina Weibo (Database)

- Oracle Database routine inspection (Database)

- Ubuntu buffalo wzr-hp-300nh brush DD-WRT router system (Linux)

- Node.js developers must know four JavaScript concepts (Programming)

- Snort build a secure Linux server (Linux)

- Linux Network Security: nmap port scanning software (Linux)

- Struts2 configure a static resource files without Struts processing (regular match) (Programming)

- MySQL use the integer type (Database)

- Using Oracle for Oracle GoldenGate to achieve a one-way data synchronization (Database)

- Linux RAID Set RAID 10 or 0 + 1 (Linux)

- Linux installation notes under GAMIT (Linux)

 
         
  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:      
 
- Configuring Android NDK development environment for Mac OS X (Linux)
- Setting Lns firewall against ARP attacks (Linux)
- Create a project using Android Studio LinearLayout (Programming)
- How to use static, class, abstract method in Python (Programming)
- The best known for archiving / compression tool under linux (Linux)
- Linux startup and logon security settings (Linux)
- Java foundation comb: Array (Programming)
- Thrift 0.9.3 compiler installation under Ubuntu (Linux)
- Build and verify MongoDB3.0.7 version (shard + replica) Cluster (Database)
- Analysis of Java keyword final (Programming)
- Network traffic monitoring ntopng (Linux)
- Oracle for Oracle GoldenGate to achieve a one-way synchronization DDL operations (Database)
- Production environment Linux bonding method standby mode slave card switch (Server)
- Ubuntu 14.04 / 14.10 how to install Mate 1.10.0 (Linux)
- Linux dmidecode command detail (Linux)
- Struts2 configure a static resource files without Struts processing (regular match) (Programming)
- RHEL 6.4 installed MySQL 5.6.27 (Database)
- Nginx server security configuration (Server)
- Nodejs complete installation instructions for Express (Linux)
- Difference in MySQL VARCHAR and CHAR data format (Database)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.