On Linux, use thescreen
is a convenient way to keep the process running continuously, even if the user disconnects the SSH connection.
I was using VSCode to connect to AutoDL, I did not know how I could keep the process running, and after reviewing the information I could use the screen command to accomplish that need.
Connecting to a remote server
First connect to the remote server using VSCode or PyCharm
Start a newscreen
conversations
screen -S mysession
-S mysession
: Name this sessionmysession
The following is an example of how this can be easily managed.
existscreen
Starting your program in a session
After starting a session, you can run any program you want to keep running, for example:
python
secessionscreen
Sessions (keeping processes running)
Press the following key combinations to detachscreen
session, but does not terminate the running program:
Ctrl + A, then D
-
Ctrl + A
This isscreen
The command prefix of the -
D
: denotes detachment.
View all currentscreen
conversations
screen -ls
Sample output: here 7171 is the session ID, mysession is the session name
There is a screen on:
(11/09/2024 08:39:43 PM) (Detached)
1 Socket in /run/screen/S-root.
Restore (reconnect) toscreen
conversations
utilizationscreen -r <session name or ID>.
to terminate the session.
# By session name
screen -r mysession
# or by session ID
screen -r 7171
If you only start ascreen
session, or you can just use it:
screen -r
end the designationscreen
conversations
utilizationscreen -X -S <session name or ID> quit
to terminate the session.
# By session name
screen -X-S mysession quit
# or by session ID
screen -X-S 7171 quit
utilizationkill
command to kill the session process.kill ID
# Kill the process
kill 7171