LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-12-2020, 04:29 AM   #1
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,327
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Ending tmux sessions automatically on SSH timeout


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
EOF
That 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?
 
Old 11-20-2020, 06:52 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,901

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
did you try to auto logout (of shell) using the variable TMOUT?
 
1 members found this post helpful.
Old 11-23-2020, 03:34 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,327

Original Poster
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
Thanks. I think TMOUT might be an answer.

Further tests in place take more time.
 
  


Reply

Tags
destroy-unattached, ssh, tmux



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Manage and Restore Tmux Sessions in Linux LXer Syndicated Linux News 0 09-04-2019 12:51 PM
LXer: Tmux Command Examples To Manage Multiple Terminal Sessions LXer Syndicated Linux News 0 06-08-2019 11:36 PM
LXer: 4 tips for better tmux sessions LXer Syndicated Linux News 0 08-27-2018 03:12 PM
LXer: Sharing Terminal Sessions With Tmux And Screen LXer Syndicated Linux News 0 09-17-2012 01:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration