Fg, bg, jobs, & amp;, nohup, ctrl + z, ctrl + c Command 1, & amp; at the end of a command, you can put this command in the background for execution, such as watch-n10shtest.sh & amp; # every 10 s in the background to execute a test. sh script 2, ctrl + z can put a command that is being executed on the foreground to the background and is paused. III,
Fg, bg, jobs, &, nohup, ctrl + z, ctrl + c command
I ,&
At the end of a command, you can put the command in the background for execution, as shown in figure
Watch-n 10 sh test. sh & # execute the test. sh script every 10 s in the background
2. ctrl + z
You can put a command that is being executed in the foreground to the background and be paused.
III. jobs
View the number of commands currently running in the background
The jobs-l option displays the PID of all tasks. jobs can be in the running, stopped, and Terminated states. However, if the task is terminated (kill), shell deletes the process ID of the task from the list known in the current shell environment.
IV. 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 (command number, not process number) to call up the selected command.
5. bg
Change a command that is paused in the background to continue execution in the background. If there are multiple commands in the background, you can use bg % jobnumber to call up the selected command.
VI. kill
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 number (PID, assumed to be pid), and then run the kill pid command.
Termination of the foreground process: Ctrl + c
VII. nohup
If the program is always executed in the background, it will be executed even if the current terminal is closed (previously & could not be done). nohup is required at this time. This command can continue running the corresponding process after you exit the account/close the terminal. After the interruption is disabled, you can no longer see the program running in the background on the other terminal jobs. in this case, you can use ps (process View command)
Ps-aux | grep "test. sh" # a: show all programs u: Display x in user-based format: show all programs, not distinguished by terminals
Process termination:
Termination of background processes: