1833451 Members
2969 Online
110052 Solutions
New Discussion

dead login sessions

 
SOLVED
Go to solution
Shivkumar
Super Advisor

dead login sessions

Dear Sirs,

Sometime after loging out from the servers the session remains active.

After few days we notice there are lots of sessions.

I am aware of that if we are not coming out by typing "exit" command then session may remain active.

Can anyone suggest what are the other reasons of remaining these login sessions active ? How to fix this ?

Thanks,
Shiv
11 REPLIES 11
Joseph Loo
Honored Contributor

Re: dead login sessions

hi,

if u mean idle sessions, u may like to enforce a timeout in either individual or all accounts.

if u mean hanged/defunct/zombie sessions, these r sessions which may die eventually. however, if u r very sure that the session may be "killed", go ahead and "kill".


regards.
what you do not see does not mean you should not believe
Arunvijai_4
Honored Contributor

Re: dead login sessions

Shiv, you can set timeout variable in .profile for users. Other reasons are, particular process started by users, remain active and waiting for some I/O. (This is because of bad programming practices)

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Muthukumar_5
Honored Contributor
Solution

Re: dead login sessions

It is because of improper logout and session hanging etc. To cotrol this, you can set TMOUT Variable in /etc/profile.

TMOUT If set to a value greater than zero, the shell
terminates if a command is not entered within the
prescribed number of seconds after issuing the PS1
prompt.

Another way is to calculate IDLE time with w command execution. Make a script and execute it with cron to check unused sessions.

-Muthu
Easy to suggest when don't know about the problem!
Indira Aramandla
Honored Contributor

Re: dead login sessions

Hi Shivkumar,

If the session are not exited properly, then they may be left has hanging sessions.

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 or the userâ s profile in their home directory.

The TMOUT parameter works in the ksh (Korn) shell, and the TIMEOUT parameter works in the bsh (Bourne) shell.

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).

For Example the following entries, in the .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


Indira A
Never give up, Keep Trying
Yogeeraj_1
Honored Contributor

Re: dead login sessions

hi shiv,

please follow the guidelines by IA above.

in the meanwhile, you can kill the old sessions by doing:
1. who -u|grep old
2. kill -9

good luck!
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Muthukumar_5
Honored Contributor

Re: dead login sessions

old is made with who -u on sessions details If more than twenty-four hours have elapsed or the line has not been used since boot time, the entry is marked old.

It will be good when you want to kill sessions more than 24 hours. To control based on time then TMOUT / who -u's month and date details.

~regards
Easy to suggest when don't know about the problem!
Kent Ostby
Honored Contributor

Re: dead login sessions

If you're intent is mostly to get rid of dead sessions, I would suggest a fairly high TMOUT value.

As someone who likes to have multiple sessions open on a server, it gets irritating when I come back the next morning and all of my sessions have timed out.

I probably would set your timeout to something large enough to span a couple of days, but that may not work for your environment.
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Bill Hassell
Honored Contributor

Re: dead login sessions

Are these simple telnet sessions initiated from PCs? If so, the standard /etc/profile has two trap statements that must be preserved. The first disables interrupts from CTRL-C and other kill signals such as hang-up. The second trap statement reenables normal trap behavior. Some sysadmins think this is a typo error and remove the last trap in /etc/profile. What this does is to disable the kernel's ability to terminate sessions which have become disconnected (known as a hang-up). Make sure that traps are enabled for these users. The command trap with no options will repoert on special handling.


Bill Hassell, sysadmin
Raj D.
Honored Contributor

Re: dead login sessions

Hi Shiv ,

Before the process goes zombie and terminates abnormally , set TMOUT variable in /etc/profile that will close the session properly.

TMOUT=value ; export TMOUT

value is a numeric value in sec for timeouttime .

Hope this will help.

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Shivkumar
Super Advisor

Re: dead login sessions

Bill, Yes. You are right. These connections are the telnet sessions initiated from the PCs using Reflection-X remote connection software tool. Please let me know exact command syntax to enter in the /etc/profile file.

best regards,
Shiv
Yogeeraj_1
Honored Contributor

Re: dead login sessions

hi shiv,

at the start of your /etc/profile, you should have the following lines:

# Ignore HUP, INT, QUIT now.
trap "" 1 2 3

then at the end:
# Leave defaults in user environment.
trap 1 2 3

hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)