In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
3.10 modify it again. After many tests, it is found that mv is not very easy to use. Instead of using mv, it is downloaded after entering the directory. This test has achieved the desired results.
The modified version is
#! / bin/bash
# download
# author:falconhero
# qq:40594324
PATH=$PATH:$HOME/bin:/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin:/root/bin
Export PATH
Mkdir-p / root/201010/ {1.. 100}
For j in {1.100}
Do
For i in {1..50}
Do
Cd / root/201010/$j
Wget https://cache.yisu.com/upload/information/20200311/30/169178.jpg &
Done
Done
The download was repeated due to carelessness. The suffix is changed to .jpg.1, and some of the original downloaded images are only halfway down, so delete the first download and keep the second download.
Find. -name\ * .jpg | xargs rm-f
Rename method:
#! / bin/bash
For i in {10..78}
Do
Cd / root/201011/$i
Rename ".jpg.1".jpg" *
Done
It can be downloaded in the virtual machine, and then exported in ftp mode.
Commonly used crt software xshell comes with ftp, which is good to use and easier to use than secureCRT. You don't have to pack and download anymore.
Virtual machine memory depending on download adjustment, 512m dead probability is very high, testing using 1 GB of memory, download process 1600 seconds, and then use top mode to view the memory usage instantly dropped to 0. 5%. And then gradually return to normal. If the 1000 + download process is started at the same time in windows, it is estimated that the system will crash directly. No attempt has been made under windows.
About 1 gigabyte of memory supports about 1600 of the download process, without much detail.
The IP address is random. Please change it to the address you want to download.
# for the time being: because a bivariate mixed number will cause $m0 $l to become a number, 0 is escaped and written as 20$ m\ 0$ l. The test is successful, because the test 20$ m\ 0$ l directory is all empty, delete
Field testing: loop variables can not be nested, there are a few variables to use a few variables, otherwise there will be additional cycles N times
Execute method chmod 755 wgetdown.sh; nohup. / wgetdown.sh &, automatically executed in the background
#! / bin/bash
# download
# author:falconhero
# qq:40594324
PATH=$PATH:$HOME/bin:/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin:/root/bin
Export PATH
Mkdir-p 20 {10.. 12} {10.. 12} / {1.. 100}
Mkdir-p 20 {10.. 12} 0 {1.. 9} / {1.. 100}
For m in {10..12}
Do
For j in {1..65}
Do
For i in {1..50}
Do
Wget https://cache.yisu.com/upload/information/20200311/30/169180.jpg
Mv * .jpg 20$ m$m/$j/
Done
Done
Done
# Delete the empty directory under the empty directory
For n in `find / root/falcon-type d-empty`
Do rmdir $n
Done
# Delete empty directory
For n in `find / root/falcon-type d-empty`
Do rmdir $n
Done
-additional tests-
Some tests.
Wget http://wvw.Domain Name.com/2010$ k/$j/$i.jpg &
# all executed in the background, but the naming will be confused and discarded (tested again and found that it will not lead to naming confusion)
Revision: will not cause naming confusion, but will lead to the consumption of a lot of memory. After all, it is equivalent to unlimited process download. That is to say, the stability of linux is good. If windows starts the 1000 process download, it will crash.
Download termination solution after closing the current window
Chmod 755 wgetlist
Nohup. / wgetlist &
It's a perfect solution. Download slowly backstage.
Exploration of the reasons:
The parent process of the process executed from the top to the background is still the process of the current terminal shell. Once the parent process exits, a hangup signal will be sent to all child processes, and the child process will exit after receiving the hangup.
An extra layer of loop variables was written during the test, but the variables were not used during the call, resulting in multiple loops
After deleting the additional variables, the desired cycle is achieved.
Conclusion: the loop statement can not write more useless variables, which will seriously affect the efficiency and execute the code N times repeatedly.
-collecting information-
Followed by reprint, notes
Http://hankjin.blog.163.com/blog/static/337319372010111492348473/
1. Using the & symbol to execute commands in the background you can add the & symbol to the Linux command or script to make the command or script execute in the background, for example:. $. / my-shell-script.sh &
For more information, please refer to this article Bg, Fg, &, Ctrl-Z-5 Examples to Manage Unix Background Jobs
two。 Use nohup to execute commands in the background after executing a command or script in the background using the & symbol, if you log out, the command will be automatically terminated. To avoid this, you can use the nohup command as follows: $nohup. / my-shell-script.sh &
For more information, please refer to this article Unix Nohup: Run a Command or Shell-Script Even after You Logout
3. Use screen to execute the command after executing the command in the background using the nohup and & symbols, the command will be executed even if you log out. However, you cannot reconnect to this session. To reconnect to this session, you can use the screen command. . Linux's screen command provides the ability to detach and reconnect a session. When you reconnect to this session, your terminal is exactly the same as when you separated. For more information, please refer to this article Screen Command Examples: Get Control of Linux / Unix Terminal
4. Using at to execute a command as a batch, using the at command, you can have a command run at a specified date and time, for example, to execute a backup script in the background at 10:00 tomorrow morning, execute the following command: $at-f backup.sh 10 am tomorrow
For more information, please refer to this article: Understand at, atq, atrm, batch Commands using 9 Examples
Some options are required to perform certain tasks in batch mode. The following article will give a detailed explanation: .How To Capture Unix Top Command Output to a File in Readable FormatUnix bc Command Line Calculator in Batch ModeHow To Execute SSH and SCP in Batch Mode (Only when Passwordless login is enabled) 5. To execute a command continuously using watch to execute a command continuously at regular intervals, you can use the watch command, as follows: $watch df-h
For more information, please refer to this article Watch: Repeat Unix Commands or Shell-Scripts every N seconds
=
4.26 follow-up
Now that I have finished my programming class with Mr. oldboy, I will continue to revise the script some day. Retest and improve the experience.
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.