Linux task management - background running and termination fg, bg, jobs, &, ctrl + z commands one, & Adding it to the end of a command can put the command into the background for execution, such as gftp &, 2. ctrl + z You can put a command that is being executed in the foreground into the background and put it in a paused state, making it unexecutable. Jobs Check how many commands are currently running in the background jobs The -l option displays the PID of all jobs. The status of jobs can be running, stopped, Terminated, but if the task is terminated (kill), the shell Delete the process ID of the task from the list known to the current shell environment; that is, the jobs command displays the information of the background running or suspended tasks in the current shell environment; 4. fg Bring the command in the background to the foreground to continue running If there are multiple commands in the background, you can use fg %jobnumber to call out the selected command. %jobnumber is the serial number of the command being executed in the background found by the jobs command (not pid) 5. bg Turn a command that was paused in the background into one that continues to execute (execute in the background) If there are multiple commands in the background, you can use bg %jobnumber to call out the selected command. %jobnumber is the serial number of the command being executed in the background found by the jobs command (not pid). Move the task to the background: First press ctrl + z; then bg, so that the process is moved to the background and the terminal can continue to accept commands. Concept: Current Tasks If there are two background task numbers, [1] and [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]" Background tasks. So we can conclude that the current tasks will change. When the user enters commands such as "fg", "bg" and "stop" without any quotation marks, the current task will be changed. Termination of a process Termination of background processes: Method 1: Use the jobs command to check the job number (assuming it is num), and then execute kill %num Method 2: Use the ps command to view the process ID (PID, assuming it is pid) of the job, and then execute kill pid Termination of the foreground process: ctrl+c Other functions of kill In addition to terminating a process, kill can also send other signals to the process. Use kill -l to view the signals supported by kill. SIGTERM is the signal sent by kill without parameters, which means that the process should be terminated, but whether it is executed or not depends on whether the process supports it. If the process has not terminated, you can use kill -SIGKILL pid. This is done by the kernel to terminate the process, and the process cannot listen to this signal. Process Suspension Background process hangs: In Solaris, use the stop command to execute, use the jobs command to check the job number (assuming it is num), and then execute stop %num; In redhat, there is no stop command. You can suspend the process by executing the kill -stop PID command. 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, and it will still be executed in the background. When you need to change it to foreground execution, execute the command fg %num. Suspension of foreground process: ctrl+Z; The above method of viewing and terminating running background programs in Linux is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to access MySql through IP address
>>: Comparative Analysis of IN and Exists in MySQL Statements
Specific method: 1. Open Command Prompt 2. Enter ...
Install First you need to install Java and Scala,...
Assume there is such an initial code: <!DOCTYP...
Table of contents 1. Introduction to binlog 2. Bi...
background: Because the server deployed the flask...
1. Using Selenium in Linux 1. Install Chrome Inst...
1. Go to the official website to download the ins...
This is an official screenshot. After MySQL 5.7 i...
Usually in project development, we have to deal wi...
This article shares the specific code for JavaScr...
tomcat is an open source web server. The web base...
Today I found this prompt when I was running and ...
Problem description: The Linux system's netwo...
1.command not found command not found 2. No such ...
Join query A join query refers to a matching quer...