当前位置:网站首页>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 !~
边栏推荐
- 详解C语言编程题:任意三条边能否构成三角形,输出该三角形面积并判断其类型
- R语言dplyr包intersect函数获取在两个dataframe中都存在的数据行、获取两个dataframe交叉的数据行
- R语言dplyr包summarise_at函数计算dataframe数据中多个数据列(通过向量指定)的均值和中位数、指定na.rm参数配置删除缺失值
- Bank of Beijing x Huawei: network intelligent operation and maintenance tamps the base of digital transformation service
- 【雲原生】 ”人人皆可“ 編程的無代碼 iVX 編輯器
- 1.会计基础--会计的几大要素(会计总论、会计科目和账户)
- Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution
- MongoDB系列之Window环境部署配置
- R语言使用glm函数构建泊松对数线性回归模型处理三维列联表数据构建饱和模型、使用step函数基于AIC指标实现逐步回归筛选最佳模型、使用summary函数查看简单模型的汇总统计信息
- 信息学奥赛一本通 1405:质数的和与积 (思维题)
猜你喜欢

710. 黑名单中的随机数

Login authentication service

Minister of investment of Indonesia: Hon Hai is considering establishing electric bus system and urban Internet of things in its new capital

710. random numbers in the blacklist

RestCloud ETL与Kettle对比分析

一篇抄十篇,CVPR Oral被指大量抄袭,大会最后一天曝光!

重磅白皮书发布,华为持续引领未来智慧园区建设新模式

The JVM outputs GC logs, causing the JVM to get stuck. I am stupid

10分钟了解BIM+GIS融合,常见BIM数据格式及特性

RestCloud ETL抽取動態庫錶數據實踐
随机推荐
【TcaplusDB知识库】TcaplusDB系统管理介绍
一键安装gcc脚本
Solution to the upper limit of TeamViewer display devices
Sikuli 基于图形识别的自动化测试技术
About selenium common. exceptions. Webdriverexception: message: an unknown server side error solution (resolved)
Pytoch deep learning code skills
小程序:uniapp解决 vendor.js 体积过大的问题
打新债注册开户安全吗,有没有什么风险?
刷题笔记(十九)--二叉树:二叉搜索树的修改与构造
权威发布 | 延安大学2022年教师岗位招聘公告
Is it safe to open a stock account through the account opening link given by the broker manager? I want to open an account
Mark一下 Unity3d在Inspector中选中不了资源即Project锁定问题
vsomeip3 双机通信文件配置
Document 1
RestCloud ETL抽取动态库表数据实践
RestCloud ETL抽取動態庫錶數據實踐
同花顺注册开户安全吗,有没有什么风险?
券商经理给的开户链接办理股票开户安全吗?我想开个户
Numpy基本使用
R语言epiDisplay包的tableStack函数制作统计汇总表格(分组的描述性统计、假设检验等)、不设置by参数计算基础描述性统计信息、指定对于大多数样本负相关的变量进行反序