Linux concurrent execution is simple, just do it this way

Linux concurrent execution is simple, just do it this way

Concurrency Functions

time for i in `grep server /etc/hosts | awk '{print $1}'`; do (ssh $i "echo 123; sleep 1; echo 456" &); done

real 0m0.063s
user 0m0.016s
sys 0m0.004s

Concurrency capabilities of xargs

time grep server /etc/hosts | awk '{print $1}' | xargs -P 24 -I {} ssh {} "echo 123; sleep 1; echo 456"

real 0m3.747s
user 0m1.136s
sys 0m0.112s

Concurrency is actually very simple. It does not require dozens of lines of golang or python code, nor does it require installation environment, compilation and other tedious steps. Just return to basics.

Summarize
The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Detailed explanation of optimizing the maximum number of concurrent socket connections in Linux
  • How to view the number of concurrent connections using the Linux netstat command
  • Various restrictions on the maximum number of concurrent socket connections under Linux (detailed explanation)
  • Configuration method for 500,000 concurrent connections in Linux
  • A brief discussion on the use of C language fork() function in concurrent programming under Linux environment
  • How to limit concurrent connections and download speed in Apache under Linux
  • Write your own concurrent queue class in Linux (Queue concurrent blocking queue)

<<:  Native js implements custom scroll bar component

>>:  Ubuntu 15.04 opens mysql remote port 3306

Recommend

JavaScript lazy loading detailed explanation

Table of contents Lazy Loading CSS styles: HTML p...

MySQL 5.7.23 installation and configuration method graphic tutorial

This article records the installation tutorial of...

Centos6.9 installation Mysql5.7.18 step record

Installation sequence rpm -ivh mysql-community-co...

IE6/7 is going to be a mess: empty text node height issue

Preface: Use debugbar to view document code in iet...

Add crontab scheduled tasks to debian docker container

Now most of the Docker images are based on Debian...

js learning notes: class, super and extends keywords

Table of contents Preface 1. Create objects befor...

Summary of DTD usage in HTML

DTD is a set of grammatical rules for markup. It i...

Docker-compose tutorial installation and quick start

Table of contents 1. Introduction to Compose 2. C...

Design Reference Beautiful and Original Blog Design

All blogs listed below are original and uniquely ...

How to install ROS Noetic in Ubuntu 20.04

Disclaimer: Since the project requires the use of...

A brief explanation of the reasonable application of table and div in page design

At the beginning of this article, I would like to ...

Detailed explanation of where the image pulled by docker is stored

20200804Addendum: The article may be incorrect. Y...