How to auto logout(timeout) a regular user and root user in Linux?

I want to set shell auto logout for multiple users with multiple timeout in linux


# touch /etc/profile.d/

# cd /etc/profile.d

Modify your script as below

# Log out in 2 minutes if the session is idle
if [ `id -nu` == "root" ];then
   export TMOUT=120
   readonly TMOUT
elif [ `id -nu` == "himanshu" ];then
   export TMOUT=60
   readonly TMOUT

Log out and re-login to validate your new changes

If you like please follow and comment