Sponsored Content
Full Discussion: Inactive Session
Top Forums UNIX for Dummies Questions & Answers Inactive Session Post 302076310 by grial on Monday 12th of June 2006 03:04:32 AM
Old 06-12-2006
Quote:
Originally Posted by System Shock
In other words:
User telnets to box, starts application.
User closes terminal without properly exiting application.
User's session terminates, but application process keeps on running.
That's what I think It is.

Quote:
Originally Posted by System Shock
I'd say first that I agree with what grial said - the app should catch ithe session being terminated -, anyway, without knowing specifics - and you know the devil is in the details -, I'd think that a simple parse of ps -ef would do the trick. Rather than looking for idle sessions, you can match PID's with a simple script. Quick example:
Thanks. Of course, I would prefer the "programming solution" but, this would be a possible one. The easy one for me.

Quote:
Originally Posted by System Shock
Code:
process=$(ps -ef | grep <my_application_process> | awk '{print $2}') 
parent=$(ps -ef | grep <my_application_process> | awk '{print $3}') 
count=$(ps -ef | grep ${parent} | wc -l)  ## this should catch at least 2 processes: 
                                          ## the PPID of application and the PID of
                                          ## user's shell
if (( ${count} < 2 )); then  ## if it only catches one, it'd mean user is no longer logged in
kill -9 ${process}
fi

Now, the above example is very simplified. You'd probably need to play around with arrays and other stuff, but hopefully it gives you the idea.

And, like I said before, if I misunderstood what's being asked, then, nevermind Smilie
But you forgot "grep -v grep" Smilie

Anyway. Doing a little search on google (I'm not a C programmer), I came across with this:

http://www.metalshell.com/view/source/92/

It's a peace of code in which signals are catched and treated. Basicaly, it uses the "signal" system call to catch a (HUP) signal. Perhaps it helps you...
 

7 More Discussions You Might Find Interesting

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

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

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

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

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

7. 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
kill.d(1m)							   USER COMMANDS							kill.d(1m)

NAME
kill.d - snoop process signals as they occur. Uses DTrace. SYNOPSIS
kill.d DESCRIPTION
kill.d is a simple DTrace program to print details of process signals as they are sent, such as the PID source and destination, signal num- ber and result. This program can be used to determine which process is sending signals to which other process. Since this uses DTrace, only users with root privileges can run this command. EXAMPLES
Default output, print process signals as they are sent. # kill.d FIELDS
FROM source PID COMMAND source command name TO destination PID SIG destination signal ("9" for a kill -9) RESULT result of signal (-1 is for failure) DOCUMENTATION
See the DTraceToolkit for further documentation under the Docs directory. The DTraceToolkit docs may include full worked examples with ver- bose descriptions explaining the output. EXIT
kill.d will run forever until Ctrl-C is hit. AUTHOR
Brendan Gregg [Sydney, Australia] SEE ALSO
dtrace(1M), truss(1) version 0.90 May 14, 2005 kill.d(1m)
All times are GMT -4. The time now is 04:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy