Ending tmux sessions automatically on SSH timeout
by Turbocapitalist from LinuxQuestions.org on (#5A9C7)
Normally, one just leaves tmux running, but in one situation I need it to go away when I am no longer actively using it.
If I have a tmux session with some windows open, I can have it killed automatically if I log out from the shell or manually close my terminal window by using 'destroy-unattached'.
Code:cat <<EOF > ~/.tmux.conf
destroy-unattached on
EOFThat covers manual shell. However, if the SSH session goes away on its own, say by just closing a laptop lid and leaving it alone, then the session remains. Or if I use ~. to close the SSH connection, the session remains, too. Maybe some specific signals need to be trapped by the shell to call a script to finish off the left over sessions?
What is a reliable way to have tmux close its sessions for that account when the SSH connection timesout?


If I have a tmux session with some windows open, I can have it killed automatically if I log out from the shell or manually close my terminal window by using 'destroy-unattached'.
Code:cat <<EOF > ~/.tmux.conf
destroy-unattached on
EOFThat covers manual shell. However, if the SSH session goes away on its own, say by just closing a laptop lid and leaving it alone, then the session remains. Or if I use ~. to close the SSH connection, the session remains, too. Maybe some specific signals need to be trapped by the shell to call a script to finish off the left over sessions?
What is a reliable way to have tmux close its sessions for that account when the SSH connection timesout?