Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Common commands for Linux background process management

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the common commands of Linux background process management". In the daily operation, I believe that many people have doubts about the common commands of Linux background process management. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "common commands of Linux background process management". Next, please follow the editor to study!

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

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 in 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 of the background task number "[2]". 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

1). Suspension of background process:

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

2) suspension of foreground process:

Ctrl+Z

At this point, the study of "common commands for Linux background process management" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report