You are not logged in.

#1 2013-11-16 05:17:57

alkor
Member
Registered: 2011-01-18
Posts: 17

[SOLVED] Necessary to keep SSH alive for remote tmux sessions? No.

Sorry I can't come up with better title for the thread.

In my case, I have a laptop and a headless box. In the headless box, I have something to run.  It should also continue to run after the ssh connection is off.

I use tmux to run the program and then Ctrl + B then D to detach. After this I type exit to stop the connection.

Now the question is: does the program run forever?



I read about ClientAliveInterval in /etc/ssh/sshd_config (if I remember correctly). The other question is: how does this work?

If on the headless machine, sshd_config has 

ClientAliveCountMax 3

and

ClientAliveInterval 120

and I do log out after the tmux detach,
which one of the following is right?

#1 The ssh session will expire in 3 x 120 seconds and the program will also stop;

#2 The ssh session will be kept alive and the program will not stop;

#3 The ssh session will expire but the program on the headless box will not stop;

#4 I got something wrong and the above doesn't make sense.

Please help.
Thanks to all who eventually read here.

Last edited by alkor (2013-11-16 23:51:18)

Offline

#2 2013-11-16 05:31:27

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Necessary to keep SSH alive for remote tmux sessions? No.

The tmux session is independent of your SSH connection. You detach from the tmux session and the close the SSH connection and then when you SSH back in, you reattach to the tmux session and it is as if you have never left. That's the whole point of tmux/screen.

The ClientAlive settings have nothing to do with tmux; they are about the resilience of your connection to the server. See man sshd_config for the details.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2013-11-16 07:31:39

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 661

Re: [SOLVED] Necessary to keep SSH alive for remote tmux sessions? No.

To reiterate what Jason said, the ClientAlive settings are about keeping an ssh connection up over a long period (e.g. sometimes needed for home routers with small NAT tables which expire the connection). That is not applicable to you here because you are completely closing your ssh connection. Your program continues to run independently on the headless server within the tmux session.

Offline

#4 2013-11-16 23:50:36

alkor
Member
Registered: 2011-01-18
Posts: 17

Re: [SOLVED] Necessary to keep SSH alive for remote tmux sessions? No.

Thanks guys. Marking [SOLVED]

Offline

#5 2013-11-17 00:42:49

Awebb
Member
Registered: 2010-05-06
Posts: 6,406

Re: [SOLVED] Necessary to keep SSH alive for remote tmux sessions? No.

Just to give you a heads up: At my last deployment, I saw a lot of tmux abuse to create background processes. If you just want to run something time consuming without being logged in all the time, have a look at nohup. There is nothing wrong with doing it in tmux, if you are the only user, but if there is a shared root account on a server, it will a) clutter up the session list and b) endanger your work by being killed during a careless "killall tmux" by another user, if he has, like so many times, blocked his tmux session with whatever renders sessions useless. Okay, this is not a tmux design flaw, but rather a human genome bug (bug report has been filed with local spiritual authority).

Offline

Board footer

Powered by FluxBB