Problem Description: A program developed on a Linux server that interrupts the execution of a remote connection, but the running program shuts down automatically as a child of the terminal window. I want the program to run in the background of the terminal, and the program can still run after the terminal is closed.
(1) To enable the program in the background to run the method
Typically, we add & to the command (such as the following statement executes the executable file in the background tcpserverfinal)
./tcpserverfinal &
Close Daemon method: Use the Jobs command to list the running processes, and use the KILL command to end the process (PID is the process number that is queried with the jobs command).
Jobs-l
Kill PID
(2) The program that has been run continues to run in the background
Ctrl+z Suspend task
Enter the BG command to put the pending task back in the background to continue execution.
(3) The program is executed in the background, and the terminal window is closed and is not interrupted as a subprocess: plus the nohup command
This closes the terminal and the program continues to run.
How to turn off the process running in the background: Use the PS-A command to query the process's PID process number, and then terminate the process with the kill command.
More related method reference: Make the program run in Linux background (turn off the terminal to continue to allow the program to run the method)