Autologout of unused terminals

John Furlani furlani at broadway.UUCP
Tue Dec 6 06:39:49 AEST 1988


In article <9012 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> In article <2682 at sultra.UUCP> dtynan at sultra.UUCP (Der Tynan) writes:
> >Anyway, perhaps you'd like to let me know
> >why it's such a terrible sin to kill these jobs.
> 
> Because any automated scheme you come up is likely to ALSO kill off
> some perfectly legitimate jobs.
> 

There has been quite a bit of chatter over wether to kill or not to kill
idle processes.  I whipped up this little C Shell script that can be used
as an example of how to kill some idle processes and not others.  A users
original shell is marked with a '-' before it.  This can be killed leaving
all background processes intact.  Unfortunately all forground processes
will be killed.  This script has a simple way of checking for these.   
The names of some processes that shouldn't be killed (e.g. vi, kermit) can
be put in a file.

The basic idea is to get the terminals that have been idle for more than
30 minutes and check to see if they're running anything important.  If
they are, don't kill them, if they aren't, kill them.  This could be
run out of cron every half hour or so.

It should be noted that this idea won't work for window systems.  My
original thought was to use it to clear modem tty's since there are
generally fewer of them and the demand is higher.

I hope this has jogged a couple of minds.  I'm not sure how many systems
this script will work for, but the principle should stay the same.  Please
mail me any suggestions or thoughts.


########################################
#     CLEARS TTY OF IDLE USERS
########################################
#
set dkill = 0
set tty_over = `who -u | awk '$6 ~ /:/ {print $2, $6}' | sed 's/0://' |
 awk '$2 > 30 {printf $1" "}'`

foreach tty ($tty_over)
    set proc_name = `ps -ft$tty | sed '1d' | awk '{print $8}'`
    foreach dont (`cat dont`)
	foreach name ($proc_name)
            if($dont == $name) then
		set dkill = 1
	    endif
	end
    end
    if($dkill == 1) then
        echo DONT KILL
        set dkill = 0
    else
	set kill_proc = `ps -ft$tty | sed '1d' | awk '$8 ~ /-csh/ {print $2}'`
	echo KILL $kill_proc
    endif
end

____________
Disclaimer:  "It's Mine! Mine! All Mine!!"
John L. Furlani 
The University of South Carolina, Columbia SC
(...!uunet!ncrlnk!ncrcae!broadway!furlani)



More information about the Comp.unix.wizards mailing list