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 > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to run linux in the background and close and view background tasks. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
In the daily development process, in addition to routine tasks and directly in the development environment such as Scripts, development, in many cases is directly started under shell (this is usually the case for small companies), take a look at the common linux background running and closing commands, here to make a summary, mainly include: fg, bg, jobs, &, nohup, ctrl+z, ctrl+c commands and so on.
First, &
At the end of a command, you can put the command in the background, as shown in
Watch-n 10 sh test.sh & # execute test.sh script in the background every 10s
Back to the top.
2. Ctrl + z
You can put a command being executed in the foreground in the background and in a paused state.
Back to the top.
III. Jobs
See how many commands are currently running in the background
The jobs-l option shows that the PID,jobs status of all tasks can be running, stopped, Terminated. But if the task is terminated (kill), shell removes the process identity of the task from the list known to the current shell environment.
Back to the top.
IV. Fg
Transfer the commands in the background to the foreground to continue to run. If you have more than one command in the background, you can call up the selected command with fg% jobnumber (the command number, not the process number).
Back to the top.
5. Bg
Change a command that is paused in the background to continue execution in the background. If you have more than one command in the background, you can use bg% jobnumber to call up the selected command.
Back to the top.
VI. Kill
Method 1: check the job number (assuming num) through the jobs command, and then execute kill% num
Method 2: check the process number of job (PID, assuming pid) through the ps command, and then execute kill pid
Termination of the foreground process: Ctrl+c
Back to the top.
7. Nohup
If the program is always executed in the background, even if the current terminal is closed (the previous & cannot be done), nohup is required. This command can continue to run the corresponding process after you exit your account / close the terminal. After turning off the interrupt, jobs can no longer see the running program in the background on another terminal, so use ps (process View Command)
Ps-aux | grep "test.sh" # a: display all programs u: display all programs in a user-based format x: display all programs, not by terminal
Process termination: kill-9 process number developed by big data, pay more attention to viewing personal data
On how to run linux background and close and view background tasks to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.