Cheap VPS host selection
Provide server host evaluation information

How to keep the program running after SSH exits

If you use SSH to connect to the remote server and still want the program to continue running after exiting the SSH session, you can use the following methods:

use nohup Command:

When starting the program, use the nohup Command to detach it from the SSH session. In this way, even if you exit the SSH session, the program will continue to run in the background and will not be affected by the SSH disconnection.

For example, to run a program in background mode, you can execute the following command:

 nohup < command > &

Among them, <command> Is the command you want to run. For example, nohup python script.py & Run in background mode named script.py Python script for.

use screen or tmux Tools:

screen and tmux It is a terminal reuse tool that provides session management functions, enabling you to start programs in a session and switch between multiple SSH sessions.

After connecting to the SSH session, install and start screen or tmux Tools (depending on your distribution and personal preferences).

stay screen or tmux Start the program that needs to run continuously in the session, and then detach the session.

After you exit the SSH session, you can reconnect to the server and reattach to the previous screen or tmux Session to view the status of the program or control it.

These methods can ensure that the program continues to run after the connection is disconnected. Choose a method that suits your needs and personal preferences to keep the program running.

Do not reprint without permission: Cheap VPS evaluation » How to keep the program running after SSH exits