start process from ssh and be able to close connection

3

I'm connecting to my RaspberryPi with Raspbian installed via ssh. My problem is that I can't let the RasPi do things (e.g., installing software, performing calculations) while my computer is shut down, since the processes I launch via SSH are child processes of the SSH shell and are terminated when the connection ends. I know I can disconnect child processes from the shell, but I'm not sure which way to use it. I would like to be able to see as much of the output of the process as possible (maybe in a file?).

BTW: I'm using PuTTY from Windows 7.

0x539

Posted 2015-04-27T16:05:40.057

Reputation: 197

Answers

2

You can use screen or tmux for that. I would prefer tmux. What tmux does is basically create different tmux sessions which keep on running even if you close your ssh session. When you reconnect later, you can re-open that session and you will see that everything is running fine.

This is a standard practice while using ssh.

For an even better interface and features, you could use byobu which uses either tmux or screen.

First of all, install byobu and tmux:

sudo apt-get install tmux byobu

Then run it like this:

byobu-tmux

Now, inside byobu, you can open several windows/tabs by pressing F2 and switch between them using <Alt>+Left/Right. Or simply press <Shift>+<F1> to see full help.

shivams

Posted 2015-04-27T16:05:40.057

Reputation: 1 269

Any chance you've got a link to a tutorial? – 0x539 – 2015-04-27T16:55:19.910

Dude, there is no need of a tutorial. Just do these 2 steps: 1) Install it and 2) Run it. Then, everytime when you reconnect to you RPi, just issue the byobu-tmux command and your previous session will open perfectly intact. – shivams – 2015-04-27T16:57:28.870

Still, if you need one, here is one good demo of using byobu: https://www.youtube.com/watch?v=NawuGmcvKus

– shivams – 2015-04-27T16:57:49.847

tmux is great! :) Any possibility to change the color of that green bar at the bottem of the console? – 0x539 – 2015-04-27T20:03:05.500

Yes, definitely. http://unix.stackexchange.com/questions/60968/tmux-bottom-bar-color-change

– shivams – 2015-04-27T20:51:30.713

1

As already mentioned, you can use a software like tmux or screen to start a shell and keep it running detached, but you could also use the nohup cmd to start your processes and keep them running even without any open session on the rasp.

Oliver Friedrich

Posted 2015-04-27T16:05:40.057

Reputation: 577

but isn't nohup one of the things which leaves you without the process stdout? – 0x539 – 2015-04-27T17:10:20.370

1Yes. But you can reconnect to that process using reptyr. – shivams – 2015-04-27T17:11:30.833

Sure you can redirect the processes output to a file. – Oliver Friedrich – 2015-04-27T19:59:49.213