Linux Process Control commands and linux Process commands
&
At the end of a command, you can put the command in the background for execution, such as gftp &.
Ctrl + z
You can put a command that is being executed in the foreground to the background, and it is paused and cannot be executed.
Jobs
View the number of commands currently running in the background
The jobs-l option displays the PID of all jobs. jobs can be in running, stopped, and Terminated State, but if the job is Terminated (kill ), the shell deletes the process ID of a task from the List known to the Current shell environment. That is, the jobs command displays information about the running or suspended tasks in the background in the Current shell environment.
Fg
Move the commands in the background to the foreground to continue running.
If there are multiple commands in the background, you can use fg % jobnumber to call up the selected command. % jobnumber is the serial number (not pid) of the command being executed in the background found through the jobs command ).
Bg
Change a command suspended in the background to continue (executed in the background)
If there are multiple commands in the background, you can use bg % jobnumber to call up the selected command. % jobnumber is the serial number (not pid) of the command being executed in the background found by the jobs command) move the task to the background to run: ctrl + z; then bg, so that the process is moved to the background to run, and the terminal can continue to accept the command.
Concept: if the current task has two backend task numbers: [1], [2]. If the first background task is successfully executed, the second background task is still in progress, the current task automatically becomes a background task with the background Task Number "[2. So we can conclude that the current task will change. When you enter commands such as "fg", "bg", and "stop", if no quotation marks are added, all changes are made to the current task.
Process Termination
Termination of background processes:
Method 1: run the jobs command to view the job number (assuming num), and then run kill % num.
Method 2: run the ps command to view the job process ID (PID, assumed to be pid), and then run the kill pid command.
Termination of the foreground process:
Ctrl + c
In addition to terminating the process, kill can send other signals to the process. You can use kill-l to view the signals supported by kill. SIGTERM is a signal sent by kill without parameters. It means that the process must be terminated, but whether the process is executed or not depends on whether the process is supported. If the process has not been terminated, you can use the kill-SIGKILL pid, Which is terminated by the kernel. The process cannot listen to this signal.
Process Suspension
Suspension of background processes:
Run the stop command in solaris, run the jobs command to view the job number (assuming num), and then run the stop % num command. in redhat, the stop command does not exist, you can run the command kill-stop PID to suspend the process. When you want to re-execute the currently suspended task, you can use bg % num to change the status of the suspended job from stopped to running, it is still executed in the background; when it needs to be executed in the foreground, Execute Command fg % num;
Pending foreground processes:
Ctrl + Z;
Command Used to view processes in linux
Ps-aux
Top
Pstree
In linux, what command is used to view the process? How to kill a process?
View processes in ps
-E: displays all processes.
-F full format.
-H does not display the title.
-L long format.
-W width output.
A displays all processes on the terminal, including those of other users.
R only displays running processes.
X shows the process without any control terminal.
Search for a process using the ps aux | grep process name.
Kill is generally used to kill processes.
For example, a ps process is as follows:
4948? Ss 0: 00 xinetd-stayalive-pidfile/var/run/xinetd. pid
Command to kill the process as kill 4948
If you want to kill a group of processes, use the killall process group name.