Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!gatech!hubcap!ncrcae!secola!broadway!furlani From: furlani@broadway.UUCP (John Furlani) Newsgroups: comp.unix.wizards Subject: Re: Autologout of unused terminals Summary: Possible Solution Message-ID: <129@broadway.UUCP> Date: 5 Dec 88 20:39:49 GMT References: <201.nlunix6@orcenl.uucp> <8978@smoke.BRL.MIL> <2682@sultra.UUCP> <9012@smoke.BRL.MIL> Organization: University of South Carolina, College of Engineering Lines: 64 In article <9012@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: > In article <2682@sultra.UUCP> dtynan@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)