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
MySQL installation (4, 5, 6 can be omitted) State...
Original article: Ultimate IE6 Cheatsheet: How To...
Let our users choose whether to move forward or ba...
question After Nginx reverse proxy, the Tomcat ap...
Step 1: Configure environment variables (my decom...
Scenario Suppose there are 10 requests, but the m...
Table of contents Component Communication Introdu...
Copy code The code is as follows: <!DOCTYPE ht...
--1. Create a new group and user for mysql # user...
If you cannot download it by clicking downloadlao...
Before understanding this problem, let's firs...
Cleanly uninstall MySQL. Personally tested, this ...
Table of contents 1. In project development, the ...
Table of contents 1. Concept of array flattening ...
This article shares with you how to use the Vue s...