≡ Menu

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.

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.

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 1 comment… add one }

  • Thangamariappan May 22, 2014, 4:09 pm

    OR
    /etc/profile
    TMOUT=300

Leave a Comment