[comp.unix.questions] How to find idle times.

jdaley%uxg.umds.lon.ac.uk@pucc.princeton.edu ( Julian Daley) (08/21/90)

The 'w' command prints out the time each logged-in user has been idle.
How do I get at that infomation 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.

Thanks,
Julian.

------------------------------------------------------------------------------
Julian Daley,              JANET: jdaley @ uk.ac.lon.umds.uxg
Guy's Hospital,      EARN/BITNET: jdaley % uxg.umds.lon.ac.uk @ ukacrl
London, England.        INTERNET: jdaley % uxg.umds.lon.ac.uk @ cunyvm.cuny.edu
-------------------------------------------------------------------------------

gaspar@stl-08sima.army.mil (Al Gaspar) (08/22/90)

> 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@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