当前位置:网站首页>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 !~
边栏推荐
- It's natural for the landlord to take the rent to repay the mortgage
- vue中缓存页面 keepAlive使用
- Use of subqueries
- [async/await] - the final solution of asynchronous programming
- View触摸分析
- Declaration and assignment of go variables
- R language uses the aggregate function of epidisplay package to split numerical variables into different subsets based on factor variables, calculate the summary statistics of each subset, and use agg
- Is the QR code for account opening given by the manager of the securities firm safe? Who can I open an account with?
- Solution to the upper limit of TeamViewer display devices
- Practical website recommendations worth collecting for College Students
猜你喜欢

Notes on writing questions in C language -- table tennis competition

RestCloud ETL解决shell脚本参数化

Unity 利用Skybox Panoramic着色器制作全景图预览有条缝隙问题解决办法

15 BS object Node name Node name String get nested node content

Login authentication service

【云原生】 ”人人皆可“ 编程的无代码 iVX 编辑器

Mark: unity3d cannot select resources in the inspector, that is, project locking

北京银行x华为:网络智能运维夯实数字化转型服务底座

Smoothing data using convolution

Talk about the RPA direction planning: stick to simple and valuable things for a long time
随机推荐
About selenium common. exceptions. Webdriverexception: message: an unknown server side error solution (resolved)
R language GLM function logistic regression model, using epidisplay package logistic The display function obtains the summary statistical information of the model (initial and adjusted odds ratio and
vsomeip3 双机通信文件配置
Redis cluster re fragmentation and ask command
网上找客户经理办理股票开户安全吗??
R语言使用ggplot2可视化泊松回归模型(Poisson Regression)的结果、可视化不同参量组合下的计数结果
SAP gui 770 下载
【 Native cloud】 Éditeur ivx Programmable par tout le monde
Go变量的声明与赋值
整理了一批脚本标准的函数模块(2021版)
nvidia-smi 报错
Use abp Zero builds a third-party login module (I): Principles
Redis cluster messages
TS common data types summary
Talk about the RPA direction planning: stick to simple and valuable things for a long time
Detailed explanation of C language programming problem: can any three sides form a triangle, output the area of the triangle and judge its type
Unity C # e-learning (10) -- unitywebrequest (2)
teamviewer显示设备数量上限解决方法
【云原生】 ”人人皆可“ 编程的无代码 iVX 编辑器
Declaration and assignment of go variables