HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
cancel
Showing results for 
Search instead for 
Did you mean: 

Inactivity Logout

 
SOLVED
Go to solution
Fred K. Abell Jr._1
Regular Advisor

Inactivity Logout

Using CDE and running HP-UX 11.11 on J6750 workstation, I want to make accounts log totally off after a certain period of inactivity. Currently the terminal locks and requires other users to use the root password to unlock, which presents its’ own set of problems. Getting users to act responsibility is out of the question. Thanks in advance.

Fred
14 REPLIES
Solution

Re: Inactivity Logout

In a real shell, you can set TMOUT to log it out after that many idle seconds.
Steven E. Protter
Exalted Contributor

Re: Inactivity Logout

Shalom Fred,

TMOUT will work for shell sessions that are idle.

Once an app is fired up, the app needs to take care of this function.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Hakki Aydin Ucar
Honored Contributor

Re: Inactivity Logout

As an example by default;

# echo $TMOUT
0
# export TMOUT=5
# echo $TMOUT
5
#
Shell will time out in 60 seconds.
rariasn
Honored Contributor

Re: Inactivity Logout

Hi Fred:

TMOUT:

You can configure the TMOUT variable to automatically lock inactive terminals.
If you use other systems often and if you copy the .profile file from one system to
another, then adding the TMOUT variable to the .profile is more convenient. If you
typically stay on one system, then either method of locking the terminal can be used.
To configure the TMOUT variable, edit the .profile file as shown in the following:
# vi ~/.profile
export TMOUT=600 # (lock after 600 seconds of inactivity)
You can change the 600 to another desired value.

CDE LOCK:
You can configure the CDE lock manager to lock your screen after a certain amount of
inactive time. To configure the CDE lock manager to lock the screen after 10 minutes
of inactive time, enter the following commands:

# cp /usr/dt/config/C/sys.resources /etc/dt/config/C/sys.resources
# vi /etc/dt/config/C/sys.resources
dtsession*lockTimeout: 10

You can also use the Style Manager task panel to adjust the CDE lock manager. To do
this, click on the screen icon.

rgs,
Matti_Kurkela
Honored Contributor

Re: Inactivity Logout

When you're using CDE, the inactivity logout is trickier to implement, because there isn't necessarily any terminals active. Also you'd want to logout the entire CDE session, not just the terminals.

If you send a "kill -HUP" to the user's dtsession process, that should kill the entire CDE session in a controlled fashion.

I don't have a workstation system available right now so I cannot check... but if the screen saver/locker causes a recognizable process to appear when it's active, it might be possible to use it as "inactivity indicator", so a relatively simple script or program should be able to detect the sessions that have been inactive for too long.

Pseudo-code:

if (there is a dtsession process running) {
identify the user running the session
if (the session has a screensaver running) {
find the start time of the screensaver process
screensaver.runtime = current_time - screensaver.starttime
if (screensaver.runtime > inactivity limit) {
kill -HUP
}
}
}

MK
MK

Re: Inactivity Logout

>Hakki: export TMOUT=5
>Shell will time out in 60 seconds.

That's 5 seconds.
Hakki Aydin Ucar
Honored Contributor

Re: Inactivity Logout

>Dennis: >>Hakki: export TMOUT=5
>>Shell will time out in 60 seconds.

>That's 5 seconds.

Yes , it is weird, is there any other parameter to set minimum timeout like 60 seconds ??

$ uname -a
HP-UX igui01 B.11.11 U 9000/800 1889900691 unlimited-user license

$ export TMOUT=1
$
shell time out in 60 seconds
$ export TMOUT=61
$ echo $TMOUT
61
$
shell time out in 60 seconds

Re: Inactivity Logout

>Hakki: it is weird, is there any other parameter to set minimum timeout like 60 seconds?

Hmm, you're saying it doesn't work as documented?
I suppose we could use tusc to see how it works.
Jim Walls
Trusted Contributor

Re: Inactivity Logout

I've run some experiments on an 11.23 server and it appears, to me, that the value of TMOUT works as fiollows:

export TMOUT=120

after an elapse of about two minute I get the...

Shell will time out in 60 seconds.

...prompt. A minute later the session disconnects.

If I interact before the 60 seconds expire, then I get another two minutes before being prompted again.

So, from my observation it seems to work, more or less, as expected.

The 60 second warning does not appear if I'm using bash but the session terminates all the same!



Hakki Aydin Ucar
Honored Contributor

Re: Inactivity Logout

>Jim: The 60 second warning does not appear if I'm using bash but the session terminates all the same!

So , 60 seconds is something hard coded OR default in somewhere as countdown to the termination ?
Jim Walls
Trusted Contributor

Re: Inactivity Logout

I haven't done an accurate timing for bash... but what appeared to happen was that after between two and three minutes the session terminated without warning.

In the sh-posix case it appears to emit the warning 60 seconds after the $TMOUT period has elapsed and then terminate 60 seconds after the warning.

I'll do a better timing with bash to confirm.
Jim Walls
Trusted Contributor

Re: Inactivity Logout

OK! Here is the session log for bash:


First: Call ssh and prime a call on date for when we return

[jimw@jimwpc3 ~]$ ssh pocuast2;date
Last login: Thu Sep 2 20:02:24 2010 from 10.81.105.17
Value of TERM has been set to "xterm".
WARNING: YOU ARE SUPERUSER !!
[root@pocuast2 /root ] exec bash
[root@pocuast2 root] date;export TMOUT=120
Thu Sep 2 21:05:57 NZST 2010
[root@pocuast2 root]
[root@pocuast2 root] timed out waiting for input: auto-logout
Connection to pocuast2 closed.
Thu Sep 2 21:08:00 NZST 2010
[jimw@jimwpc3 ~]$

As you can see, the total duration was about a little over TWO minutes.

Next I logged a sh-posix session:

[jimw@jimwpc3 ~]$ ssh pocuast2;date
Last login: Thu Sep 2 21:05:13 2010 from 10.81.105.17
Value of TERM has been set to "xterm".
WARNING: YOU ARE SUPERUSER !!
[root@pocuast2 /root ] date;export TMOUT=120
Thu Sep 2 21:17:24 NZST 2010
[root@pocuast2 /root ]
Shell will time out in 60 seconds.
sh: Timed out waiting for input.
Connection to pocuast2 closed.
Thu Sep 2 21:20:24 NZST 2010
[jimw@jimwpc3 ~]$

As you can see, POSIX shell users get a wrning and an extra 60 seconds ;O)








Re: Inactivity Logout

>Jim: Shell will time out in 60 seconds.
>...prompt. A minute later the session disconnects.

Yes.

>Hakki: 60 seconds is something hard coded

TGRACE is hard coded as 60.

>Jim: In the sh-posix case it appears to emit the warning 60 seconds after the $TMOUT period has elapsed and then terminate 60 seconds after the warning.

My experiments with real shells indicate you get TMOUT, then you get a 60 grace period. Then:
sh: Timed out waiting for input.
Hakki Aydin Ucar
Honored Contributor

Re: Inactivity Logout

>Dennis: TGRACE is hard coded as 60.

>Jim: >>

My experiments with real shells indicate you get TMOUT, then you get a 60 grace period. Then:
sh: Timed out waiting for input.


So , Timeout gracely manner is valid for POSIX and other shells like KSH;

# ksh
# echo $0
ksh
# export TMOUT=5
#
shell time out in 60 seconds
((AFTER 60 seconds, because I changed my shell from POSIX to ksh,otherwise it would be terminated))
ksh: timed out waiting for input