I think this is either going the wrong way, or maybe I'm not understanding what's being said.
The "idle process" you are talking about is not telnet or the shell, but rather an instance of the application that's being run through said telnet session, right?
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.
And what you want to find out is how to differenciate those application processes that are still running that where not properly shut down when the user terminated his telnet session, so you can safely kill them. Right?
If that's the case, i.e., the application process doesn't die when the telnet session is killed, then loking at user idleness is not going to help, since there actually won't be a user session associated with said application process.
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:
user1 logs in, so it creates some processes. One of the is the user's shell. When that user starts some application, that application process should show the user's shell as the application process' parent ID. I would think a simple match of said IDs in a cron job would do the trick; something like:
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
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
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
But you forgot "grep -v grep"
Anyway. Doing a little search on google (I'm not a C programmer), I came across with this:
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...
This is exactly the problem I am facing now. But it is not necessary user logout abnormally, sometime could be due to network connection failure and caused the application ended. I noticed that the shell and the application PID are both still active. Below are some typical example that extract from server.
root# who |grep 10.1.1.144
jbmkt1 pts/82 Jun 22 11:11 (10.1.1.144)
jbmkt1 pts/83 Jun 22 09:50 (10.1.1.144)
jbmkt1 pts/226 Jun 22 10:34 (10.1.1.144)
jbmkt1 pts/249 Jun 22 10:53 (10.1.1.144)
root@ # ps -ef |grep db |grep jbmkt1
jbmkt1 20432 20331 2 10:53:34 pts/249 0:52 /u/recital/db.exe -x menu
jbmkt1 22156 22089 0 11:11:46 pts/82 0:00 /u/recital/db.exe -x menu
jbmkt1 17993 17948 2 10:34:44 pts/226 0:54 /u/recital/db.exe -x menu
jbmkt1 10055 9955 2 09:50:55 pts/83 2:27 /u/recital/db.exe -x menu
root # ps -u jbmkt1
9955 pts/83 0:00 sh
20432 pts/249 1:00 db.exe
22156 pts/82 0:00 db.exe
20331 pts/249 0:00 sh
22089 pts/82 0:00 sh
17948 pts/226 0:00 sh
17993 pts/226 1:03 db.exe
10055 pts/83 2:37 db.exe
from the above you can see those logins earlier have ended abnormally due to network problem, but the session seems still active for both shell and application, I will have to manually verify and kill those inactive session, if not the load will getting higher and slower.
This is what I meant, but if you based on the count, it is also appropriate, right ?
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)
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)
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)
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)
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)
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)