Operating System - Linux
1753861 Members
7408 Online
108809 Solutions
New Discussion юеВ

Re: script for logging off users who are idle

 
SOLVED
Go to solution
John Jimenez
Super Advisor

Re: script for logging off users who are idle

Pat,
Yes if you would not mind, could you e-mail it to jimenez-j@iehp.org?
Hustle Makes things happen
Fabio Ettore
Honored Contributor

Re: script for logging off users who are idle

Hi John,

I don't know scripts to logout users who are idle.
Anyway a possible solution is keepalive parameters.

ndd -h | grep -i keepalive

You will see more details by

ndd -h

Hope this helps you.

Best regards,
Fabio
WISH? IMPROVEMENT!
John Jimenez
Super Advisor

Re: script for logging off users who are idle

Thanks for the help, But I will have to find another way. The sessions sitting in the app never go into an idle state even though they are not doing anything.
Hustle Makes things happen
Mel Burslan
Honored Contributor

Re: script for logging off users who are idle

I do not know the nature of your application but when they run, i.e., not sit idle on the screen, if they accumulate CPU time for the shell they are running under, you can collect this information by the help of ps and awk commands and decide who is idle and who is depending on the accumulated cpu time per process. Just a wild idea.
________________________________
UNIX because I majored in cryptology...
Tom Schroll
Frequent Advisor

Re: script for logging off users who are idle

Well, if you are NOT at a shell prompt (which eliminates the ability to use autologout in tcsh for example), then I suggest a C program that runs as a background system process (daemon), reads the utmp file to get the tty for each user logged into the system, and then do a stat() on the device file to get the last timestamp (indicating activity on the tty). I think this is how the "idle" output of the "w" command is determined. I already have a program written in "C" to "watch" users who log in and out. With some work, it could be adapted to look for idle users, and then kill the session. It has not been tested on HP-UX greater than 11.0 though. Let me know if you are interested. The project spans more than one "C" file though...so I can't really post it here. I could possibly make these additions in my spare time, but I can't guarantee how long it would take for me to finish. :-) I hope that you or someone else can use the info that I provided above to write your own version.
:-) Good luck!

-- Tom
If it ain't broke, it needs optimized.
John Jimenez
Super Advisor

Re: script for logging off users who are idle

Tom,

I am the Admin here. Max, who is the programmer, is not here today. Would it be to much to ask you to send me what you have already. I am sure that he can modify it accordingly. If so my email adress is Jimenez-J@iehp.org

Thanks again,
John
Hustle Makes things happen
Juan M Leon
Trusted Contributor
Solution

Re: script for logging off users who are idle

Hi John try "idled", it is a freeware with C source, your programer can modify and compile it according to your company needs.
http://www.darkwing.com/idled/
Tom Schroll
Frequent Advisor

Re: script for logging off users who are idle

John,

I took a quick look at "idled" and it actually seems to do exactly what you need. So take a look. If you have trouble getting it to work or still need me to send you the code that I have (which would need modification to do what you need), let me know. Take care.

-- Tom
If it ain't broke, it needs optimized.
Juan M Leon
Trusted Contributor

Re: script for logging off users who are idle

Something to Add to Tom Schroll, If I am correct, after you download the source code the default make file is set to be used on SUN OS, you will need to comment that section and uncomment the HP section. after that you can compile and install the software.

Thanks

Juan
Gordon  Morrison
Trusted Contributor

Re: script for logging off users who are idle

Try this:

#!/bin/ksh
who -u | cut -c 1-10,38-50 | egrep "[12][0-9]:|old" > /var/tmp/current
for IDLE_USR in `cat /var/tmp/current | awk '{print $3}'`
do
# kill -9 $IDLE_USR
echo $IDLE_USR
done


This will kill any login shell where the user has not typed anything for 10 hours or more.
When you've tried it out and are happy that it is choosing the right processes to kill, remove the comment from the kill line and delete the echo line.

Share And Enjoy
What does this button do?