You are not logged in.
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
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.
Offline
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
Thanks guys. Marking [SOLVED]
Offline
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