idle time for w command

Paul Slootman slootman at dri.nl
Tue Apr 30 17:20:10 AEST 1991


jik at athena.mit.edu (Jonathan I. Kamens) writes:
>In article <4274 at pluto.dss.com>, cat at pluto.dss.com (Iain Wacey) writes:
>|> How does the w command determine how long someone has been idle?
>
>  It checks the access time on the device file (i.e. the st_atime field of the
>stat structure obtained by calling stat() on the user's tty device.
>
>|> We are
>|> writing a login protocol using our own devices and w always reports
>|> users on these devices as being idle for a long period of time.
>
>  Do your devices correctly update their access times when appropriate?

I once hacked a program to show idle time (on our System V, we don't
have 'w'). Only checking the access time (and mod. time) on the device
file may not be enough; if the user is running some program that sits
around calculating something for 20 minutes without generating any
output, the user is apparently idle (hmmm, I guess *he* is, the
terminal isn't...).

If your 'ps' has a field to show the state of the process (e.g. S for
sleeping less than 20 seconds, I for sleeping longer than 20 seconds),
you can double-check by running 'ps'.

Paul.
-- 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
: slootman at dri.nl           : You are wise, witty and wonderful, but you      :
: ...!hp4nl!dri500!slootman : spend too much time reading this sort of trash. :
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



More information about the Comp.unix.programmer mailing list