码迷,mamicode.com
首页 > 系统相关 > 详细

shell 多进程

时间:2017-08-03 18:50:59      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:后台   i++   oca   ima   shell   log   blog   res   host   

shell 多进程来模拟多线程

(1){ } 建立代码块

(2)使用 & 将进程放入后台

[zheng@localhost ~]$ cat threads.sh 
#!/bin/bash

for ((i=0;i<5;i++))
do
{
    sleep 3
    echo $i>>aa && echo $i
}&
done
wait
cat aa | wc -l
rm aa

result

技术分享

shell 多进程

标签:后台   i++   oca   ima   shell   log   blog   res   host   

原文地址:http://www.cnblogs.com/cpuz/p/7281158.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!