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

How to view background processes by Linux

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how Linux looks at background processes. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

The LINUX background process, also known as the daemon (Daemon), is a special process running in the background. It is independent of the control terminal and periodically performs certain tasks or waits for certain events to be processed.

1. Run the .sh file

You can run it directly with the. / sh file, but if you want to run in the background, you need the nohup command and the & command even if you close the current terminal.

(1) & Command

Function: add to the end of a command, you can put this command in the background to execute

(2) nohup command

Function: run commands without hanging up

2. View the commands currently running in the background

There are two commands available, jobs and ps, the difference is that jobs is used to view the tasks running in the background of the current terminal, which cannot be seen by changing the terminal. On the other hand, the ps command is used to view the dynamics of the instant process, and you can see the background processes running by other terminals.

(1) jobs command

Function: view the tasks currently running in the background of the terminal

The jobs-l option shows that the status of the PID,jobs for all tasks on the current terminal can be running,stopped,Terminated. The + sign indicates the current task, and the-sign indicates the latter task.

(2) ps command

Function: view all current processes

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

3. Close the commands currently running in the background

Kill command: ending process

(1) View jobnum through the jobs command, and then execute kill% jobnum

(2) check the process number PID through the ps command, and then execute kill% PID

If it is a foreground process, you can terminate it by executing Ctrl+c directly.

4. Switching and control of front and background processes.

(1) fg command

Function: 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 first view the jobnun with jobs, and then call up the selected command with fg% jobnum.

(2) Ctrl + z command

Function: put a command being executed in the foreground in the background and be in a paused state

(3) bg command

Function: 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 first view the jobnum with jobs, and then call up the selected command with bg% jobnum to continue execution.

Thank you for reading! This is the end of this article on "how to view background processes in Linux". I hope the above content can be of some help to you, so that 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.

Share To

Development

Wechat

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

12
Report