Solved running processes over ssh so that they don't die when the connection is interrupted

decuser

Well-Known Member

Reaction score: 126
Messages: 272

What are some of the options for long running processes over ssh so that they don't get killed when a network interruption occurs? I've used tmux/screen in the past, but really, I prefer a simple xterm connection. I've also used nohup, but I don't know if that's misuse or correct use. Is there anything like a reconnectable ssh session - something like what tmux does?
 
OP
decuser

decuser

Well-Known Member

Reaction score: 126
Messages: 272

OK. Pretty much what I thought. I hadn't heard of dtach, which is pretty cool, but tmux is what I've used in the past. I was hoping there was a hidden ssh parameter or something similar :)
 

Zirias

Son of Beastie

Reaction score: 1,553
Messages: 2,673

I was hoping there was a hidden ssh parameter or something similar :)
Well, ask yourself, how should this work?

Processes start with three standard streams connected to the controlling terminal (if not redirected somehow): stdin, stdout and stderr.

Of course, you can launch a process "in the background", and you can add redirections so it isn't confused when one of the streams is suddenly closed, and even more, you can insert a parent process like nohup that will "eat" the HUP signal when you disconnect from your shell, so the process doesn't terminate in response to it.

But there can't be any way to reconnect the I/O streams to a different terminal (of your next login) without a parent process that keeps running and manages that.

I didn't know about dtach, it's obviously the most light-weight solution to offer this, without even keeping a buffer of the terminal contents. But really, if you need to re-attach a process, tmux is the perfect tool for that :)
 
Top