当前位置:网站首页>Shell script multi process concurrent writing method example (high level cultivation)
Shell script multi process concurrent writing method example (high level cultivation)
2022-06-26 15:09:00 【BOGO】
There are many real work scenarios to achieve rapid processing , And use concurrent execution . Other languages are very easy to implement concurrency .
that shell Script most linux The most friendly scripting language above can achieve concurrency ?
The answer is yes !~
So, BOGO, here is an example to share with you !~
#!/bin/bash
# Concurrency number
pnum=6
# The function you want to execute
task () {
echo "$u start"
sleep 5
echo "$u done"
}
FifoFile="$$.fifo"
mkfifo $FifoFile
exec 6<>$FifoFile
rm $FifoFile
for ((i=0;i<=$pnum;i++));do echo;done >&6
# perform 20 Time
for u in `seq 1 20`
do
read -u6
{
# Call function
task
# Print result log of concurrent execution function
[ $? -eq 0 ] && echo "${u} Success " || echo "${u} Secondary failure "
echo >&6
} &
done
wait
exec 6>&-Apply the above example to realize concurrent processing !~
边栏推荐
- Login authentication service
- 功能:crypto-js加密解密
- R语言glm函数逻辑回归模型、使用epiDisplay包logistic.display函数获取模型汇总统计信息(自变量初始和调整后的优势比及置信区间,回归系数的Wald检验的p值)、结果保存到csv
- Talk about the recent situation of several students from Tsinghua University
- TCP拥塞控制详解 | 1. 概述
- Halcon C # sets the form font and adaptively displays pictures
- Redis cluster re fragmentation and ask command
- Pod scheduling of kubernetes
- Numpy基本使用
- Common operation and Principle Exploration of stream
猜你喜欢
随机推荐
The engine "node" is inconsistent with this module
Halcon C# 设置窗体字体,自适应显示图片
Unity 利用Skybox Panoramic着色器制作全景图预览有条缝隙问题解决办法
kubernetes的Controller之deployment
ETL过程中数据精度不准确问题
R language uses GLM function to build Poisson logarithm linear regression model, processes three-dimensional contingency table data to build saturation model, uses step function to realize stepwise re
一键分析硬件/IO/全国网络性能脚本(强推)
RestCloud ETL抽取动态库表数据实践
clustermeet
Unity C# 网络学习(九)——WWWFrom
5张图诠释了容器网络
vsomeip3 双机通信文件配置
Principle of TCP reset attack
Is it safe for flush to register and open an account? Is there any risk?
Mark一下 Unity3d在Inspector中选中不了资源即Project锁定问题
Bank of Beijing x Huawei: network intelligent operation and maintenance tamps the base of digital transformation service
Pod scheduling of kubernetes
It's natural for the landlord to take the rent to repay the mortgage
[async/await] - the final solution of asynchronous programming
15 BS object Node name Node name String get nested node content









