[Reprint] linux running in the background on and off, see linux background tasks running in the background and close view background task

linux running in the background and close view background task

https://www.cnblogs.com/huey/p/4871468.html

 

  Read catalog

fg、bg、jobs、&、nohup、ctrl+z、ctrl+c 命令

One,&

Finally add a command, you can put this command into the background, such as

watch -n 10 sh test.sh & # 10s performed once every script in the background test.sh

二、ctrl + z

You can command being executed in a foreground into the background, and paused.

Three, jobs

See how many commands are currently running in the background

PID jobs -l option to display all tasks, jobs status can be running, stopped, Terminated. But if the task is terminated (kill), shell delete tasks from a known list of the current shell environment process identity.

Four, fg

The command in the background adjusted foreground continue to run. If more than one command in the background, you can use fg% jobnumber (is the command number, not the process ID) selected command recall.

Five, bg

A pause command in the background, becomes the background to continue. If more than one command in the background, you can use bg% jobnumber the selected command recall.

Six, kill

  • Houko 1: View command jobs through job number (assumed num), and then execute kill% num
  • 2 another way: View job process ID (PID, assuming pid) by the ps command and then kill pid

Terminate the foreground process: Ctrl + c

Seven, nohup

If you let the program is always in the background, even if you close the current terminal also performs (before & can not do), this time the need nohup. The command to exit your account / continue to run the process after closing the corresponding terminal. After closing the interruption, in another terminal run background jobs you have not seen the program, this time using the ps (process view command)

ps -aux | grep "test.sh" #a: displays all programs u: user-based format to display x: displays all programs, not to the terminal to distinguish

 

Process termination: 

Background process termination:

fg、bg、jobs、&、nohup、ctrl+z、ctrl+c 命令

One,&

Finally add a command, you can put this command into the background, such as

watch -n 10 sh test.sh & # 10s performed once every script in the background test.sh

二、ctrl + z

You can command being executed in a foreground into the background, and paused.

Three, jobs

See how many commands are currently running in the background

PID jobs -l option to display all tasks, jobs status can be running, stopped, Terminated. But if the task is terminated (kill), shell delete tasks from a known list of the current shell environment process identity.

Four, fg

The command in the background adjusted foreground continue to run. If more than one command in the background, you can use fg% jobnumber (is the command number, not the process ID) selected command recall.

Five, bg

A pause command in the background, becomes the background to continue. If more than one command in the background, you can use bg% jobnumber the selected command recall.

Six, kill

  • Houko 1: View command jobs through job number (assumed num), and then execute kill% num
  • 2 another way: View job process ID (PID, assuming pid) by the ps command and then kill pid

Terminate the foreground process: Ctrl + c

Seven, nohup

If you let the program is always in the background, even if you close the current terminal also performs (before & can not do), this time the need nohup. The command to exit your account / continue to run the process after closing the corresponding terminal. After closing the interruption, in another terminal run background jobs you have not seen the program, this time using the ps (process view command)

ps -aux | grep "test.sh" #a: displays all programs u: user-based format to display x: displays all programs, not to the terminal to distinguish

 

Process termination: 

Background process termination:

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12199538.html