The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-06-2006
Registered User
 

Join Date: Feb 2006
Posts: 6
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
Reply With Quote
Forum Sponsor
  #2  
Old 06-06-2006
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
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...
Reply With Quote
  #3  
Old 06-06-2006
Registered User
 

Join Date: Feb 2006
Posts: 6
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 ?
Reply With Quote
  #4  
Old 06-07-2006
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
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...
Reply With Quote
  #5  
Old 06-07-2006
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
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...
Reply With Quote
  #6  
Old 06-07-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 555
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
Reply With Quote
  #7  
Old 06-08-2006
Registered User
 

Join Date: Feb 2006
Posts: 6
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0