当前位置: 首页 > news >正文

德州购物网站建设/重庆森林讲的什么内容

德州购物网站建设,重庆森林讲的什么内容,綦江网站建设公司,汕头人大shell脚本再执行过程中就一个进程&#xff0c;从头到尾 下面配置shell脚本执行过程中启动多个进程同时执行 #!/bin/bashfor ((i1;i<10;i)) do (echo "$i"sleep 10 ) & done wait echo -E "########## $SECONDS ##########"注&#xff1a; $SECONDS&…

 

shell脚本再执行过程中就一个进程,从头到尾

下面配置shell脚本执行过程中启动多个进程同时执行

#!/bin/bashfor ((i=1;i<=10;i++))
do
(echo "$i"sleep 10
) &
done
wait
echo -E "########## $SECONDS ##########"

注:

$SECONDS:是执行完脚本所用的时间   

wait:是等待所有的进程执行完毕

执行结果   

[root@wcy ~]# bash test.sh 
1
2
3
4
5
6
7
8
9
10
########## 10 ##########

进程查看

[root@wcy ~]# ps -ef | grep test.sh 
root 1764 1565 0 19:23 pts/1 00:00:00 bash test.sh
root 1765 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1766 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1767 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1770 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1772 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1773 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1774 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1776 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1777 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1778 1764 0 19:23 pts/1 00:00:00 bash test.sh
root 1786 1708 0 19:23 pts/2 00:00:00 grep test.sh

 

[root@wcy ~]# ps -ef | grep test.sh | grep -v grep | wc -l
11

查看同一时刻多少个sleep在跑

[root@wcy ~]# ps -ef | grep sleep | grep -v grep 
root 2168 2165 0 21:59 pts/1 00:00:00 sleep 10
root 2169 2166 0 21:59 pts/1 00:00:00 sleep 10
root 2172 2167 0 21:59 pts/1 00:00:00 sleep 10
root 2174 2171 0 21:59 pts/1 00:00:00 sleep 10
root 2175 2173 0 21:59 pts/1 00:00:00 sleep 10
root 2176 2170 0 21:59 pts/1 00:00:00 sleep 10
root 2179 2177 0 21:59 pts/1 00:00:00 sleep 10
root 2181 2178 0 21:59 pts/1 00:00:00 sleep 10
root 2182 2180 0 21:59 pts/1 00:00:00 sleep 10
root 2184 2183 0 21:59 pts/1 00:00:00 sleep 10

  

[root@wcy ~]# ps -ef | grep sleep | grep -v grep  | wc -l
10

多进程的shell脚本可以用于并行执行多任务

#!/bin/bash
for ((i=1;i<=1;i++))
do
(
for ((num=1;num<=100;num++))
doecho "task1-- $num"sleep 1
done
) &
(
for ((ber=1;ber<=100;ber++))
doecho "task2-- $ber"sleep 1
done
) &
done
wait

效果,两个同时执行

[root@wcy ~]# bash duo.sh 
task2-- 1
task1-- 1
task2-- 2
task1-- 2
task2-- 3
task1-- 3
task2-- 4
task1-- 4
········

脚本进程

[root@wcy ~]# ps -ef | grep duo.sh | grep -v grep 
root 2221 1491 0 22:13 pts/0 00:00:00 bash duo.sh
root 2222 2221 0 22:13 pts/0 00:00:00 bash duo.sh
root 2223 2221 0 22:13 pts/0 00:00:00 bash duo.sh

同时执行的进程

[root@wcy ~]# ps -ef | grep sleep | grep -v grep 
root 2357 2223 0 22:14 pts/0 00:00:00 sleep 1
root 2358 2222 0 22:14 pts/0 00:00:00 sleep 1

 

转载于:https://www.cnblogs.com/LuckWJL/p/9674347.html

http://www.lbrq.cn/news/1554445.html

相关文章:

  • 四川城乡住房和城乡建设厅网站首页/百度人工服务热线电话
  • 途牛企业网站建设方案/郑州整站网站优化
  • 网站屏蔽右键/游戏推广怎么做挣钱
  • 加盟什么网站建设/青岛seo博客
  • 求做政府采购网站/引流最好的推广方法
  • 男女做暧暧网站免费/百度关键词推广方案
  • 网站建设协议书 印花税/江苏营销型网站建设
  • 结构设计在哪个网站接单兼职做/新seo排名点击软件
  • 怎么看自己网站的空间/百度搜索广告推广
  • wordpress教程lnmp/抖音seo软件工具
  • seo服务理念/优化模型数学建模
  • 考试网站怎么做的/泰州seo推广公司
  • 网站建设制作文案/企业宣传片视频
  • 惠州做网站多少钱/免费建站免费网站
  • 做淘宝设计能做网站吗/网站搜索引擎优化情况怎么写
  • 网站开发手册/网络销售好不好做
  • 新闻头条新闻/seo会被取代吗
  • 在国外做盗版网站吗/关键词搜索爱站网
  • 北京西站附近的景点有哪些/网络舆情信息
  • 有没有个人做的网站赚流量费/上海网站优化公司
  • 哪个网站做加盟的比较靠谱/百度最新秒收录方法2021
  • 四川省住房和城乡建设厅网站无法进入/百度快照网站
  • 网站建设维修服务流程/百度首页关键词推广
  • 如何判断网站html5/说到很多seo人员都转行了
  • 如何在阿里云云服务器上搭建网站/网络营销发展现状与趋势
  • 苏州市建设交易中心网站首页/重庆网
  • 建站国外百元服务器/培训心得体会怎么写
  • 网站流程图/杭州优化建筑设计
  • 动态网站开发的感想/seo网站诊断报告
  • 建站公司专业团队/国内前10电商代运营公司
  • 服务器管理与配置学习总结
  • 【CV 目标检测】Fast RCNN模型②——算法流程
  • 文件快速复制工具,传输速度提升10倍
  • 登录与登录校验:Web安全核心解析
  • Mac(一)常用的快捷键整理
  • 哈希表特性与unordered_map/unordered_set实现分析