If I run a python script on a RPi2 from an ssh session, that script stops once the ssh session is terminated. How do I make that python script run in the RPi2 indefinitely and irrespective of what happens with the ssh session? Just run it from the local pi user? I don't have a monitor on my pi so is there a way to make it run as local from a remote computer?
Just add an ampersand at the end of the command line. For example
$ python start_server.py
becomes
$ python start_server.py &
Hi, thanks. Where does that line go exactly?
Currently I ssh into the pi, go to the python script's directory and type:
python myscriptname.py
So you're saying that if I type in the start_server.py line first, itll make my script run indefinitely and irrespective of ssh session state?
Thx again.
Just add "&" at the end of that line. (Not sure if a space is necessarily; I always use it.) But yes, the script will continue running after you kill your ssh session. Let me know if that doesn't work, but I tested it right before making that post.
Also for a fancier solution consider read
this. In the past, it was more trouble than it was worth for me but it's still pretty awesome.
Hello!
Look at
tmux. You can create a session, run some program in it and then detach from the session. Every time you login to a machine locally or remotely you can attach to this session by its name and see what is going on with the program/script. You can create "windows", panes and run what you want in every pane.
Just the first from DuckDuckGo:
Basic tmux Tutorial - Windows, Panes, and Sessions over SSH - Youtube.
Thanks! Gr8 stuff! Im using tmux