How to keep processes running after ending ssh session?

Hi everyone!

Sometimes due some reasons we need to launch any process via ssh and keep it running after ending the ssh session.

The following instruction helps you to save your time.

Connect to certain machine via ssh

ssh username@ip_address

If you use ubuntu then make sure screen is already installed on the machine you need keep any process running after endind ssh session.

screen -v

If you see the output like below that means the screen is already installed on the machine and you can skip installation step

Screen version 4.03.01 (GNU) 28-Jun-15

Installation step (Ubuntu only)

sudo apt install screen

Running step 

screen # press space if required run the necessary process CTRR+A CTRL+D # now you can close the ssh session exit

Resume screen session

If you need to resume screen session you priviosly executed and to stop the process then perform commands below

ssh username@ip_address screen -r # capture the screen session you launched before CTRL+C # to stop process if it has been run in main tread or kill by pid if process in bg exit # exif from screen exit # exit from ssh

Have a good day!