If I close a SSH connection will a running process also stop?

So as I said in the title it’s very simple. I connect to my droplet with SSH then, I start a process for example with PM2 and I close the SSH connection. Will the PM2 process still run or will it get terminated?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @lidistat67,

The PM2 process shouldn’t terminate itself upon your exit.

Having said that, there is another solution which I believe it’s always considered good practice to be executed and that’s using SCREEN.

This is for situations where you perform a long-running task on a remote machine, and suddenly your connection drops, the SSH session is terminated, and your work is lost.

Starting Linux Screen To start a screen session, simply type screen in your console:


This will open a screen session, create a new window, and start a shell in that window.

You can start any command there as with your normal shell. Once you do start it and you want to leave the command as it is, you just need to press


This will detach your screen session and return you to your initial bash window.

To return to your screen session, you’ll first need to check it’s ID. You can see the ID by executing the below

screen -ls

Then to re-enter your screen session type in

screen -r IDNumberHere

Alternatively, PM2 is the tool for some long-running tasks. I just wanted to present you with an example.

Regards, KFSys