Program to log off idle users

James Cummings james at dlss2.UUCP
Sat Oct 6 02:53:40 AEST 1990


In article <1990Oct4.135333.19139 at warwick.ac.uk> cudcv at 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 at hpbbi4.BBN.HP.COM> eugen at 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.



More information about the Comp.unix.admin mailing list