In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to implement multi-threaded script files in Shell". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
That is, for example, I have 100 executable files that have no special sequential execution relationship with each other, such as CODE:
The code is as follows:
Job_1
Job_2
Job_2
.
Job_100
Want to use csh/bash for multithreaded call execution.
For example, if you open five threads at a time, then job_1,2,3,4,5 starts first, and if any of these threads executes completion first, it continues to execute the next file that has not been executed at the beginning, such as job_6,7,8...., which always executes all 100files with the specified number of threads.
I wanted to use "&" to put it in the background, but in this way I can specify 5 at a time, but I can't know when any of these programs will be finished, so I can't move on to the next program.
The perfect solution:
The code is as follows:
-(dearvoid@LinuxEden:Forum)-(~ / tmp)-
[$$= 6718 $? = 0]; cat job_1
#! / bin/bash
((RANDOM% 5 + 1))
Echo "$0 sleeping for $n seconds..."
Sleep $n
Echo "$0 exiting..."
-(dearvoid@LinuxEden:Forum)-(~ / tmp)-
[$$= 6718 $? = 0]; for ((I = 2; I
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.