In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to achieve BASH multi-process parallel processing in Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve BASH multi-process parallel processing in Linux" this article.
The code is as follows:
#! / bin/bash
SEND_THREAD_NUM=13
The ID number of the current process that the tmp_fifofile= "/ tmp/$$.fifo" # script runs as the file name
Mkfifo "$tmp_fifofile" # create a new random fifo pipeline file
Exec 6 "$tmp_fifofile" # definition file descriptor 6 points to this fifo pipeline file
Rm $tmp_fifofile
For ((iTuno)
For i in `seq 100`; do # 100th for cycle starts
Read-u6 # reads lines from file descriptor 6 (actually points to the fifo pipe)
{
Echo $I # print I
Sleep 3 # pause for 3 seconds
Echo > & 6 # writes a blank line to the fifo pipe file again.
} &
# {} this part of the statement is executed as a child process in the background, so you don't have to wait 3 seconds at a time.
# next, this part of the echo $I is completed almost at the same time, and the for loop is completed when the 13 blank lines in the fifo are read.
# continue to wait for the fifo data to be read in read, and when the 13 sub-processes in the background wait for 3 seconds, in order
# queue to enter blank lines into fifo, so that there is data in fifo again, and the for statement continues to execute
Id printing! # print the last child process to enter the background
Echo $pid
Done
Wait
Exec 6 > &-# Delete file descriptor 6
Exit 0
These are all the contents of the article "how to implement BASH multi-process parallel processing in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.