Linux下shell并发执行

来源:互联网 发布:聚力体育 for mac 编辑:程序博客网 时间:2024/06/06 03:20
#!/bin/bashSEND_THREAD_NUM=30function Run(){    tmp_fifofile="/tmp/$$.fifo"    mkfifo "$tmp_fifofile"    exec 6<>"$tmp_fifofile"    rm $tmp_fifofile    for((i=0; i < $SEND_THREAD_NUM; i++)); do         echo     done >&6    cat $1 | while read line    do         read -u6         {            #the command you want to paralell execute             echo >&6         }&   done   wait   exec 6>&-   echo "Success"}

其中,SEND_THREAD_NUM为并发线程数,可以自己根据实际情况修改,在“the command you want to paralell execute”下面填上想并发执行的脚本就可以了

备注:while循环读取的是需要批量执行的机器的iplist。

原创粉丝点击