Inactive Session


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Inactive Session
# 1  
Old 06-06-2006
Inactive Session

Hi, I am new to forum, I am wondering anyone can help me ?

Is there a command to tell whether a particular process is already inactive, so I can issue a kill command to end it. I have been encountering scenerio whereby users always shutdown abnormally by closing the windows, and my application cannot end by itself. Therefore I will have to manually check and kill manually, otherwise my server uptime will go up very fast.

Appreciate if anyone can help on this. Many thanks in advance.

Best Rgds
T.W.Low
# 2  
Old 06-06-2006
That looks like a programming matter... You should "catch" the closing window event or whatever it's called.. Or something like that... ¿? don't know...
# 3  
Old 06-07-2006
Hi Grial,

Thanks for dropping by. All our session are telnet session and running some xbase application via some emulator software. How do I "catch" the closing window event ? Can ps -ef tell if a process has become inactive ?
# 4  
Old 06-07-2006
Well, of course I'm not sure If you could do this but, when you close a telnet session, the shell sends a HUP signal to all his child process when the session is finished. Prehaps you only have to catch that signal and close your app then...
# 5  
Old 06-07-2006
It comes to my mind one thing...
who -u gives you info about login sessions. One of the fields is "line activity". You could check (with a crontab, for example) this time and kill the user (last field of de output is the pid of the sell) when he/she reaches x time of inactivity... But this will only work while the user is logged in...
# 6  
Old 06-07-2006
I'm not very good at shell programming though, you can use following code to kill users who are inactive for more than 30 minutes:
Code:
#!/bin/ksh
clear
who -u > ./aaa
grep -v "\." aaa > bbb

count=0;

while read a b c d e f g;
do
hour=$(echo $f | head -c 1)
min=$(echo $f | tail -c 3)
let minute=$hour*60+$min
if [ $minute -gt 30 ]; then
echo "KILLING USER........ :$a \n IDLE SINCE..........: $minute MINUTES"
kill -9 $g
let count=$count+1
fi
done < ./bbb
echo "\n\n TOTAL USERS KILLED..:$count\n"

You can modify this as per your requirements.

Regards,
Tayyab
# 7  
Old 06-08-2006
Hi all,

Thanks for your reply.

But I think if a session is idling for 30 mins, no necessary it is inactive, right ?

Some of the sessions if it is generating report, then can easily takes hours, I can't just kill the session just like that. I think who -u might help in this case, to check if any login have x time of inactivity, so that I can judge from there what session can be killed.

Too bad, there is no command that can tell if a session is completely dead. In this case, I will have to check manually.

Thanks and have a nice day.

With regards
T.W.Low
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Solaris

Difference between the desktop session and console session

what is the difference between desktop session and console session in solaris as i am wondering we use option -text for the former and -nowin for the later (1 Reply)
Discussion started by: kishanreddy
1 Replies

2. Shell Programming and Scripting

Determining if session is a login session

Besides 'who am i' and 'tty' what commands could be used to determine if a session is interactive as compared to a web process or cron process. Any command should work with the common unix variants. (3 Replies)
Discussion started by: jgt
3 Replies

3. HP-UX

ssh session getting hung (smilar to hpux telnet session is getting hung after about 15 minutes)

Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (1 Reply)
Discussion started by: yoda9691
1 Replies

4. Solaris

I am not able to login in gnome session and java session in Sun solaris 9& 10

I am not able to login in gnome session and java session in Sun solaris 9& 10 respectively through xmanager as a nis user, I am able to login in common desktop , but gnome session its not allowing , when I have given login credentials, its coming back to login screen, what shoul I do to allow nis... (0 Replies)
Discussion started by: durgaprasadr13
0 Replies

5. Shell Programming and Scripting

Hiding Directories on a Session by Session basis

Hi, Apologies if anyone has read my recent post on the same subject in the Linux forum, just thought actually the solution might more likely come from scripting. Essentially, I am trying to restrict access to directories based on the user's name AND their location on a session-by-session... (3 Replies)
Discussion started by: en7smb
3 Replies

6. Shell Programming and Scripting

sqlplus session being able to see unix variables session within a script

Hi there. How do I make the DB connection see the parameter variables passed to the unix script ? The code snippet below isn't working properly. sqlplus << EOF user1@db1/pass1 BEGIN PACKAGE1.perform_updates($1,$2,$3); END; EOF Thanks in advance, Abrahao. (2 Replies)
Discussion started by: 435 Gavea
2 Replies

7. UNIX for Advanced & Expert Users

inactive pages

hi, plz tell me, how can get the inactive pages in HP UX. bye.... (1 Reply)
Discussion started by: venkat_t
1 Replies
Login or Register to Ask a Question