In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Linux task management-background operation and termination
Fg, bg, jobs, &, ctrl + z commands
First, &
Add to the end of a command, which can be executed in the background, such as gftp &
2. Ctrl + z
A command that is being executed in the foreground can be put in the background and is paused and cannot be executed.
III. Jobs
See how many commands are currently running in the background
Jobs
The-l option shows the PID,jobs status of all tasks. It can be running, stopped.
Terminated, but if the task is terminated (kill), shell
Removes the process identity of a task from the list known to the current shell environment; that is, the jobs command displays information about tasks that are running or suspended in the background in the current shell environment
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 use fg% jobnumber to call up the selected command.% jobnumber is the sequence number (not pid) of the command being executed in the background found through the jobs command.
5. Bg
Change a command that is paused in the background to continue execution (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.% jobnumber is the sequence number (not pid) of the command being executed in the background found through the jobs command.
Transfer the task to run in the background:
First ctrl + z; then bg, so that the process is moved to the background and the terminal can continue to accept commands.
Concept: current task
If there are two task numbers in the background, [1], [2]; if the first background task is successfully completed and the second background task is still being executed, the current task will automatically become the background task number "[2]".
The backstage mission. So it can be concluded that the current task will change. When a user enters commands such as "fg", "bg" and "stop", without any quotation marks, what is changed is the current task
Termination of the process
Termination of background process:
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 foreground process:
Ctrl+c
Other functions of kill
Kill can not only terminate the process, but also send other signals to the process. Using kill-l, you can see the signals supported by kill.
SIGTERM is a signal sent by kill without parameters, meaning that the process should be terminated, but whether it is executed or not depends on whether the process supports it or not. If the process has not been terminated, you can use kill-SIGKILL pid, which terminates the process by the kernel, and the process cannot listen for this signal.
Suspension of a process
Suspension of background processes:
Execute through the stop command in solaris, check the job number (assuming num) through the jobs command, and then execute stop% num
In redhat, there is no stop command, so you can suspend the process by executing the command kill-stop PID
When you want to re-execute the currently suspended task, you can change the status of the suspended job from stopped to running through bg% num, which is still executed in the background; when you need to execute it in the foreground instead, execute the command fg% num
Suspension of the foreground process:
Ctrl+Z
The above article in Linux to view and terminate the running background program method is the editor to share with you all the content, I hope to give you a reference, but also hope that you support more.
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.