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

by on January 4, 2011 · 1 comment· LAST UPDATED December 4, 2012

in , ,

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.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 Thangamariappan May 22, 2014 at 4:09 pm

OR
/etc/profile
TMOUT=300

Reply

Leave a Comment

Tagged as: , ,

Previous Faq:

Next Faq: