Bash Configure Automatic Logout [ Linux / Unix / Apple OS X ]

How can I configure automatic logout for my bash shell under Unix / Apple OS X / Linux operating systems?\

You can configure any modern shell including bash to auto logout. Please note that autologout will only work for the foreground process. For example, if you left your session idle the automatic shell logout will occur. But, if an interactive process such as top command or a vi text editor session is left idle, then automatic logout would not occur.

ADVERTISEMENTS

Configuration

Add the following lines to your bash startup file such as $HOME/.bash_profile or create a new bash shell script called timout-settings.sh in the /etc/profile.d directory:

## append in $HOME/.bash_profile
## 300 seconds == 5 minutes ##
TMOUT=300
readonly TMOUT
export TMOUT

OR /etc/profile.d/timout-settings.sh

#!/bin/bash
## 300 seconds == 5 minutes ##
TMOUT=300
readonly TMOUT
export TMOUT

Save and close the file.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • Thangamariappan May 22, 2014 @ 16:09

    OR
    /etc/profile
    TMOUT=300

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.