When you close your putty or terminal with ssh connection, session with all commands usually closing or killing. To prevent it we can use one easy command — screen
Screen — like tabs, the ability to start parallel processes, like windows, but in a console. You can exit the server, leaving any process to work in a screen or several screens on server.
Upon returning, you simply activate the hidden screen and see again the command that has not been interrupted all this time.
In fact, it is keeping of SSH Sessions running after disconnection
First, if you have not this software install it:
sudo apt install screen
So, how to keep processes running after ending ssh session?
Even if you just type this command, everything will work. A unique identifier will be added to the screen, knowing which you can return to it. But it is better to use the names of screens
1. Display all running screens
2. Create your own with the name «pip»
screen -S pip
In the «new» console you can launch everything you want, as in a simple console. No difference.
3. Minimize (hide) your screen
Press: Ctrl + A, then press: D
4. Return to your screen
screen -r pip
5. Exit and final work with screen
I start Python processes or any long working script in the screen so that they work, if that is without me, otherwise when disconnecting from ssh, the command terminates.
I recommend you to use screen, or analog commands like tmux, nohup, Byobu, and some other.
Don’t forget you can start any command in background, just add & in the end
python3 manage.py runserver &