LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Flagging a Warning Message with TMOUT (https://www.linuxquestions.org/questions/linux-newbie-8/flagging-a-warning-message-with-tmout-726195/)

Hi_This_is_Dev 05-15-2009 07:49 AM

Flagging a Warning Message with TMOUT
 
Hi All,


I have just come to know that we can use the environmental variable TMOUT to set an idle time in seconds after which any inactive session is automatically logged out.

In order to achieve this, we can do the following:

Edit /etc/profile file and write the line:

Code:

TMOUT=3600
This will log out any user who has been inactive for 1 hour.

Well, can we do something more with it? I mean, can we flag a warning message on the user's screen just before logging him/her out? Such as: Your session will be automatically logged out in .. seconds.

Any creative ideas?


Regards,
Dev.

PTrenholme 05-15-2009 08:50 AM

A search for the tmout flagged threads found one suggesting a script based on the who command or just changing to the ksh as your default, and the ksh gives a 1 minute warning message prior to terminating the shell.

Note, however, that the TMOUT variable is a shell-specific setting, not a session-specific one. If you look at the output of who -uT you'll see something like this:
Code:

$ sudo who -uT
[sudo] password for Peter:
Peter    ? :0          2009-05-15 05:58  ?          2658
Peter    + pts/0        2009-05-15 05:59 00:37        2756 (:0)
Peter    - pts/1        2009-05-15 06:23  .          5261 (:0.0)

Note that the X-session (:0) is flagged as having an "unknown" message reception state, and an unknown idle time.

Bottom line: I think you'll need to write a "widget" to monitor your X-server activity and add it to the X-server init script if you want to be able to automatically terminate an idle X session.

Or, here's a thought: Use one of the power management applications, and set the actions you want to happen after specific idle times.

Hi_This_is_Dev 05-16-2009 05:58 PM

Okay, I will try that and post here my finding. Thanks a lot!


All times are GMT -5. The time now is 08:56 AM.