System idle time under Linux

Hugo Léveillé hugol at fastmail.net
Thu Sep 30 06:58:47 EDT 2010


Ok after some testing, what the who -Hu is giving me is the idle time of
each running open shell. The first line always return a "?" as the IDLE
time.

ex:

NAME     LINE         TIME             IDLE          PID COMMENT
vg0619hl :0           2010-09-30 06:10   ?         13091
vg0619hl pts/1        2010-09-30 06:27 00:11       14084 (:0.0)
vg0619hl pts/2        2010-09-30 06:54   .         14084 (:0.0)




On Thu, 30 Sep 2010 02:26 -0700, "John Pinner" <funthyme at gmail.com>
wrote:
> On Sep 29, 7:36 pm, Hugo Léveillé <hu... at fastmail.net> wrote:
> > Good point
> >
> > One I am looking for, is time since last user mouse or keyboard action.
> > So I guess I am looking for the exact same thing a screensaver is
> > looking for
> 
> The command
> 
> who -Hu).
> 
> 
> will give you idle time for each logged-in user
> 
> ( H - print headers; u - list users )
> 
> and you could run this command via subprocess, then read and parse its
> output.
> 
> Alternatively you could parse the same file(s) as who - I think it
> reads /var/run/utmp - but that would be a lot more work, as it is a
> binary file (run man utmp to see its format, use the struct module to
> decode)
> 
> Best wishes,
> 
> John
> --
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
  Hugo Léveillé
  hugol at fastmail.net




More information about the Python-list mailing list