Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running tmux on my servers and when configuring things I like to just su into root and take care of things. Is there a possibilty to log out root automatically after I detach the tmux session?

share|improve this question

2 Answers 2

There's TMOUT:

   TMOUT  If  set to a value greater than zero, TMOUT is treated as the default timeout for the read builtin.  The select command terminates if input does not arrive after TMOUT seconds when input is      
          coming from a terminal.  In an interactive shell, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt.  Bash terminates  after  waiting  for
          that number of seconds if input does not arrive.

You could set this in /etc/profile if the EUID is root.

The problem with this is that it requires a compatible shell.

An alternative would be Timeoutd, but I don't know where it's available (debian-based seems to have it, rhel-based doesn't).

share|improve this answer
    
Thanks, I know TMOUT, is there another way to do this? Something that triggers on detach? –  thpetrus Feb 8 '13 at 13:42
    
@thpetrus I mentioned timeoutd as an alternative. –  fuero Feb 8 '13 at 13:46
    
Yes, but it's basically the same as TMOUT and doesn't trigger on detach. –  thpetrus Feb 8 '13 at 16:57

TMUX is designed to survive unintentional and intentional disconnects, as you already are aware.

You could have a bash_logout file that kills the server with the kill-server command. This would not be internal to tmux, obviously, but would have the desired effect.

Alternatively, have it use kill-session specifically.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.