In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to execute the code in batches under Linux. It is very detailed and has a certain reference value. Friends who are interested must finish it!
The method of batch execution of code under Linux. Complex can be written in snakemake definition rules, simple shell can be written directly.
Sample code
What you want to achieve:
1, there are 0-9, 10 folders
2. Go to the folder and execute the run.sh script. Because it takes a long time to run, you want to use nohup run.sh & to put it in the background, and save the running log nohup.out at the same time.
1for I in [0-9] *; # 1
2 do
3 cd $I; # 2
4 nohup run.sh &; # 2
5 cd.. /
6done
Error
Because I used the & symbol in the middle, I entered the background ahead of time and couldn't get into the next loop.
If not &, then it is executed sequentially and cannot be carried out in batches.
1for I in [0-9] *; # 1
2 do
3 cd $I; # 2
4 nohup run.sh; # 2
5 cd.. /
6done
Success Code 1for I in [0-9] *; # 1
2 do
3 cd $I; # 2
4 echo "nohup run.sh &" | bash; # 2
5 cd.. /
6done
Here, nohup one-line command, first print with echo, complete the command nohup run.sh &, and then use | bash to execute the previous command, which will achieve what I want to achieve.
Code written in one line
1for I in [0-9] *; do cd $I; echo "nohup run.sh &" | bash; cd.. /; done
The above is all the contents of the article "how to execute Code in batch under Linux". Thank you for reading! Hope to share the content to help you, more related 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.