How to find idle times.

Al Gaspar gaspar at stl-08sima.army.mil
Wed Aug 22 22:06:11 AEST 1990


> The 'w' command prints out the time each logged-in user has been idle.
> How do I get at that infomat> ion myself, without grep'ing etc the output ?
> The /etc/utmp file dosen't store this information, so it must come from
> somewhere else (kmem ?).

> Any pointer gratefully received.

The way finger does it is to get the user's tty from /etc/utmp and then
do a stat on /dev/userstty.  The st_atime member of the stat struct
obtained, being the last access time, will allow you to determine the
idle time.  I hope this helps.

Cheers--

Al

-- 
Al Gaspar	<gaspar at stl-08sima.army.mil>
USAMC SIMA, ATTN:  AMXSI-TTC, Box 1578, St. Louis, MO  63188-1578
COMMERCIAL:  (314) 331-4354	AUTOVON:  555-4354
uunet.uu.net!stl-08sima.army.mil!gaspar



More information about the Comp.unix.questions mailing list