Reputation: 711
I am currently implementing a web server on a raspberry py using the web.py framework. For convenience, I am using ssh, so I can perform tests on the raspberry directly from my laptop.
My problem is that I can't close the ssh session without the web server stopping to work, because when the session closes, a logout is performed automatically.
Does anyone know a possibility to avoid the logout while closing the ssh session? I am using Linux on both my laptop and the raspberry. Thank you.
Upvotes: 3
Views: 3321
Reputation: 7544
The best way to do this is by using screen
. It lets you "multiplex" your command line, meaning you can run multiple commands at the same time. Also, when you exit your ssh session, the commands running in screen will continue to run, and it is very easy to install as well.
Here's a guide for installing and running it, and if you have any other questions, comment or google for more screen guides
Edit in 2022: These days many people prefer tmux to screen. My personal recommendation would be tmux, but both do the trick!
Upvotes: 4
Reputation: 517
I have raspLite on the raspberry pi 3 model b and this is how i used screen
in the bash enviroment.
ssh pi@hostname
apt-get install screen
screen
npm start
Then I close the terminal and the webserver continues untill i use the SIGINT kill command on the pid.
Upvotes: 0