![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sqlplus session being able to see unix variables session within a script | 435 Gavea | Shell Programming and Scripting | 2 | 07-03-2006 07:11 AM |
| Canīt logout to user inactive | lalox | UNIX for Dummies Questions & Answers | 1 | 07-31-2004 06:31 AM |
| inactive pages | venkat_t | UNIX for Advanced & Expert Users | 1 | 04-26-2002 09:25 AM |
| wired and inactive pages | manjunath | High Level Programming | 1 | 04-05-2002 03:34 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
||||
|
||||
|
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
|
||||
|
||||
|
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" Regards, Tayyab |
|
#7
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|