I like to use a program called screen
It starts a new separate terminal "screen" from where you go do all the same stuff as in a terminal but if you loose connection that "screen" continues to run on its own thread uninterrupted. You can come back and reconnect to it later.
To install it simply do ...
apt-get install screen
to use it simply type screen
. You will be teleported into the new screen :) Run the program that needs to run forever.
While in a screen ...
- Detach from screen
ctrl + a + d
- Kill screen
ctrl + a + k
Outside the screen ...
- Show all running screens and their names
screen -ls
- Reconnect to a screen
screen -r <session id/name>
- Start a screen with human name
screen -S <session name>
The contents of the screen are buffered so when you reconnect see the output and you can use ctrl + pageup
but sometimes it does not work and you need enable some other stuff. It is good to write a log file whether you are running it as thread &
or screen
.
Screen can be used for allot of other things too. Read the documents.
Capitals matter. I run many programs like this on the Pi and it has been a fantastic tool since the invention of Unix :)