This widget could not be displayed.
Operating System - HP-UX
1845515 Members
2224 Online
110244 Solutions
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
New Discussion
This widget could not be displayed.
This widget could not be displayed.

Re: auto logout user & kill expire process

 
Kelvin Ng
Advisor

auto logout user & kill expire process

1) How to terminate user session & force quit from application if IDLE for a specific time example 15 minutes, each user use their own . profile

2) How to automate kill inactive & expire process/session, sometimes user just close the application without proper logout OR with proper logout, but certain process still runnnig with ? when i run ps -ef,
at this moment i just know how to use kill -9 to kill the inactive process

like both users in the attachment file, they already logout from application
7 REPLIES 7
VEL_1
Valued Contributor

Re: auto logout user & kill expire process


1. You can force a terminal to log out after a period of inactivity by setting the TMOUT and TIMEOUT parameters in the /etc/profile file. The TMOUT parameter works in the ksh (Korn) shell, and the TIMEOUT parameter works in the bsh (Bourne) shell.

The following example, taken from a .profile file, forces the terminal to log out after an hour of inactivity:

TO=3600
echo "Setting Autologout to $TO"
TIMEOUT=$TO
TMOUT=$TO
export TIMEOUT TMOUT


2. Mostly, the user's application will be exited when user session closed except if we used command like "nohub" .

Indira Aramandla
Honored Contributor

Re: auto logout user & kill expire process

Hi Kelvin,

To drop idle sessioon try using the shell variables such a TMOUT.

The idle telnet session can be automatically cleared by setting the timeout value. A non-zero value specifies the number of minutes to wait before an idle telnet session is timed out. The minimum value is 1 minute, the maximum is 512640 minutes (1 year).

You can sett the TIMEOUT value to 15 minutes in the users profiles who use that application.


Indira A
Never give up, Keep Trying
Ranjith_5
Honored Contributor

Re: auto logout user & kill expire process

Hi Kelvin,

At my place it is set in /etc/profile for 5 mins.I have added the following

export TMOUT=300


If you need to set timeout only for specific users then add the same entry in .profile for those users.

Regards,
Syam
Kelvin Ng
Advisor

Re: auto logout user & kill expire process

i create a new user, login & get the $ without any profile setting, is sh shell, put TMOUT into .profile, it work

i logon with my userID with own profile that bring me to application menu, at the $, is ksh, put TMOUT into .profile, it doesn't work

Kelvin Ng
Advisor

Re: auto logout user & kill expire process

To whom it may concern,

i put the TMOUT=15 in my home directory .profile, it auto logout & close the session when only i exit from application menu & get the $, refer to attach doc file.

it won't auto logout when i still inside my application menu.

(my requirement is we would like to logout ceratin IDLE users from their application menu)


As for killing inactive/expire process, someone tell my to write a script & put in cron job, does any one have the scripts ?, will it kill of those process started by root or other important users ?
Gordon  Morrison
Trusted Contributor

Re: auto logout user & kill expire process

Hi Kelvin,
TMOUT won't kill any sessions that have a sub-process (child) running for a good reason: If you're running a program/script that takes a long time, ending it prematurely could cause data corruption.

I've attached a script that I use. Among other things, it checks for old logins and kills them if they have no children, and if they are not on a list of users NOT to kill.
It's designed to be run remotely via ssh, but it also works locally.
What does this button do?
Gordon  Morrison
Trusted Contributor

Re: auto logout user & kill expire process

Here's another script that will clean up 'phantom' logins from utmp. These occur when a user doesn't logout cleanly, and the shell exits, but utmp doesn't get updated.
What does this button do?