1830624 Members
2131 Online
110015 Solutions
New Discussion

Re: Terminate idle login

 
peterchu
Super Advisor

Terminate idle login

Our HP UX system limited the no. of user login , could suggest how to terminate the idle login ( eg. 2 hours ) ? could anyone post the script for reference ? Thx.
2 REPLIES 2
Mark Grant
Honored Contributor

Re: Terminate idle login

In the users .profile or in /etc/profile add

"export TMOUT=xxxx" where xxxx is the number of seconds that user can remain idle without being logged out.
Never preceed any demonstration with anything more predictive than "watch this"
Elmar P. Kolkman
Honored Contributor

Re: Terminate idle login

Or use the w command, grep the idle timeouts of more then 2 hours. This will lead to the tty being used. Then you can kill all processes running on that tty.

w | awk '$4 ~ /[2-9]:[0-9]*/ {print $2}
$4 ~ /[0-9][0-9][0-9]*:[0-9]*/ {print $2}'

This will give the ttys with idle times of at least 2 hours.
Now you can use ps -t to get processes running there and kill those... Or just: fuser -k /dev/ should do the trick.
Every problem has at least one solution. Only some solutions are harder to find.