1. Run the .sh file You can run it directly using the ./sh file, but if you want to run it in the background even if you close the current terminal, you need the nohup command and the & command. (1) & Command Function: Add to the end of a command to execute the command in the background (2) nohup command Function: Run commands without interruption 2. View the commands currently running in the background There are two commands available, jobs and ps. The difference is that jobs is used to view the tasks running in the background of the current terminal, which cannot be seen if the terminal is changed. The ps command is used to view the dynamics of the instantaneous process and can see the background processes running in other terminals. (1) jobs command Function: View the tasks running in the background of the current terminal The jobs -l option can display the PID of all tasks in the current terminal. The status of jobs can be running, stopped, or Terminated. The + sign indicates the current task, and the - sign indicates the next task. (2) ps command Function: View all current processes ps -aux | grep "test.sh" #a: Display all programs u: Display in user-based format x: Display all programs, regardless of terminal 3. Close the command currently running in the background kill command: end the process (1) Check jobnum through the jobs command, and then execute kill %jobnum (2) Use the ps command to view the process ID PID, and then execute kill %PID If it is a foreground process, just execute Ctrl+c to terminate it. 4. Switching and control of foreground and background processes (1) fg command Function: Move the command in the background to the foreground to continue running If there are multiple commands in the background, you can first use jobs to view jobnum, and then use fg %jobnum to call out the selected command. (2) Ctrl + z command Function: Put a command being executed in the foreground into the background and put it in a paused state (3) bg command Function: Turn a command that is paused in the background into one that continues to execute in the background If there are multiple commands in the background, you can first use jobs to view jobnum, and then use bg %jobnum to call out the selected command for continued execution. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: MySQL installation tutorial under Windows with pictures and text
>>: One-click installation of MySQL 5.7 and password policy modification method
Solution: Just set the link's target attribute...
Some projects have relatively simple business, bu...
Original link: https://vien.tech/article/157 Pref...
The four property values of position are: 1.rel...
Statement 1: <link rel="shortcut icon"...
In order to efficiently meet requirements and avo...
MySQL error: Error code: 1293 Incorrect table def...
Table of contents Prototype chain diagram Essenti...
Table of contents 1. Download the system image fi...
Table of contents 1. Problem 2. Solution Option 1...
1. Open port 2375 Edit docker.service vim /lib/sy...
Dockerfile is a text file that contains instructi...
Say goodbye to the past Before vscode had remote ...
In our recent project, we need to use Google robo...
Table of contents I. Definition 2. Usage scenario...