Remotely connect to the Linux server to run the program. If the local computer is shut down, the Linux server program will also be disconnected. This is because after the connection is disconnected, the terminal will receive a SIGHUP (hang-up) signal to close the sub-process of the session.
There are several ways to solve this problem:
1. Use the nohup command, add nohup before the command, and add the & symbol after the command to make the program run in the background and ignore SIGHUP signal 1. For example: nohup ping 127.0.0.1 &. nohup redirects the output of the program to the nohup.out file in the current directory or in the $HOME directory.
2. Use the screen command to create a virtual terminal and run program 2 in it. For example: screen -S name creates a virtual terminal named name, and then runs the program in it. If you want to exit the virtual terminal, you can press the Ctrl+A+D key combination. If you want to re-enter the virtual terminal, you can use the screen -r name command.
3. Use the Ctrl+Z key combination to suspend the program, and use the bg command to put it in the background. For example: run the python tt.py program, press Ctrl+Z to suspend it, and then enter bg %1 to put it in the background.
Here is the second method
screen -S name
Open a new terminal
to activate the environment
, open visdom
, and then open a session, repeat the previous steps, train the network,
and then
close the remote connection. Re-open the remote connection, enter
to open a new session, and then enter to
find that it is still running, end!
Screen close command
1. Ctrl + A, Ctrl + \ - Exit the screen and terminate all programs running in the screen. This command is suitable for use when a tty connection needs to be closed.
2. Ctrl + D, D or Ctrl + A, Ctrl + D - "Minimize" the screen and let it run in the background. This command is suitable for use when you need to leave the screen temporarily but don't want to close it. It can be restored with screen -r.
3. Ctrl + A, Q - Closes all areas except the current area.
4. Ctrl + A, X - Close current area.
When there are two sessions with the same name
There are several suitable screens on:
145282.name (03/09/2023 07:23:56 AM) (Detached)
130910.name (03/08/2023 01:00:00 PM) (Detached)
method
screen -d -r 145282.name
Ctrl + A, Ctrl + \ (或者输入exit)
screen -d -r 130910.name
Ctrl + A, Ctrl + \ (或者输入exit)