
In the UNIX & Linux operating system, the BASH, zsh, and ksh shell environment have the ability to control the minimum and maximum period time for a user to stay in a system. If the time is exceeded, it will automatically log off the user out from the system.
From the man bash, TMOUT, If set to a value greater than zero, TMOUT is treated as the default timeout for the read builtin. The select command terminates if input does not arrive after TMOUT seconds when input is coming from a terminal. In an interactive shell, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. Bash terminates after waiting for that number of seconds if input does not arrive.
1. Add the following parameters in /etc/profile and set the time out for <numbers> seconds.
# vi /etc/profile TMOUT=<numbers-in-seconds> export TMOUT
# TMOUT=<numbers-in-seconds> # export TMOUT # echo $TMOUT
2. Log off from your system and make a new connection. Wait for <numbers> seconds and you will be automatically log off!
Shell will time out in 60 seconds. ksh: Timed out waiting for input. Connection closed.
Additional note:
• The TMOUT counts the seconds when there is no key is pressed on the keyboard during a session. As an example scenario, if you are transferring a huge file and take a very long time to finish, the TMOUT counts will stop counting till the transferring process is done. If the transferring process is done, the TMOUT will start counting and when time is exceeded, it will kick any idle user.
• Only applies to BASH, zsh, and ksh shell environment.
• TMOUT will not work when you are opening a file (using cat, more) or using the vi editor.
• The time out is calculated in seconds
• export TMOUT=0, means no time out set
3. TMOUT can be changed by any user unless it is given the readonly option.Add the following parameters in /etc/profile.
# vi /etc/profile export TMOUT=<numbers-in-seconds> readonly TMOUT