Path: utzoo!attcan!uunet!cs.utexas.edu!sun-barr!newstop!texsun!csccat!dalnet!dlss2!james From: james@dlss2.UUCP (James Cummings) Newsgroups: comp.unix.admin Subject: Re: Program to log off idle users Message-ID: <94@dlss2.UUCP> Date: 5 Oct 90 16:53:40 GMT References: <10504@hacgate.UUCP> <9800001@hpbbi4.BBN.HP.COM> <1990Oct4.135333.19139@warwick.ac.uk> Reply-To: james@dlss2.UUCP (James Cummings) Organization: RedRock Development Lines: 26 In article <1990Oct4.135333.19139@warwick.ac.uk> cudcv@warwick.ac.uk (Rob McMahon) writes: >I'm guessing a bit at this script, because it's full of SystemV-ism's, and >this article is not about critising code, but ... > >In article <9800001@hpbbi4.BBN.HP.COM> eugen@hpbbi4.BBN.HP.COM (#Eugen Bauknecht) writes: >>who -u | awk '{print $2,$6}' > /tmp/kltmp0 > >(Sorry what's who -u ? Is this a System-V ism ? I'll assume $2 is the >terminal, and $6 is the `idle time', got by checking the mtime & atime of the >tty). who -u is a shell method of finding not only who is on, but the amount of "idle" time and their process id, etc. System-V ism?? could be but I believe I've seen it on other systems also, not all but (again I think) some BSDs (newer versions maybe?). At anyrate it is NOT a sure fire way to gauge "idleness". I wrote, and haven't finished smoothing out some of the edges on, a C implementation that looks directly at the utmp file for struct utmp.ut_type equal to "7"(a USER_PROCESS) and guages time by calling stat() against the utmp.ut_line (tty line) for last modified time. As I understand it, the who -u shell command can be fooled(fact) by even a loop which echos a bell character to the screen, but this method requires(?) keyboard input to change the modify time. Systems that do not support the utmp file or don't allow access to it would have to take a totally different approach. I'd be interested, just for the knowledge, to know how this would be implemented without a utmp.