Shell support function control, with the following command to achieve the front and rear switch: 1. command& let the process run in the background 2. Jobs view Process 3 running in the background. FG%n Let the background run the process N to the foreground to 4. BG%n Let the process n Go backstage
5. Kill%n kills Job PS: "N" is the job number that the jobs command sees, not the process number. FG, BG, Jobs, &, CTRL + Z are all related to system tasks, although it is not necessary to use these commands, but learning is also very practical.
One, & most often used this is used at the end of a command, you can put this command in the background to execute
Two, CTRL + Z can put a command executing in the foreground in the background, and pause
Iii. jobs See how many commands are currently running in the background
FG will move 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 bring up the selected command,%jobnumber is the ordinal (not PID) of the command being executed in the background through the jobs command.
BG will be a command paused in the background to continue execution if there are multiple commands in the background, you can use BG%jobnumber to bring up the selected command,%jobnumber is the serial number (not the PID) of the command being executed in the background through the jobs command.
Example: Suppose you find that a program running in the foreground takes a long time, but you need to do something else, you can use CTRL-Z to terminate the program, and then you can see the system prompt: [1]+ Stopped./start.sh If you do not have this prompt, use the jobs command to view the task: # jobs[1]+ suspended./start.sh & then we can schedule the program to execute in the background: (the number behind BG is the job number) #bg 1[1]+./start.sh & View running tasks with the jobs command: #jobs [1] + Running./start.sh & If you want to bring it back to the foreground, you can use #fg 1./start.sh so that you can only wait for this task to complete on the console.
Switching between a Linux task and a front desk