Linux – How to read the “IDLE” column in the output of the Linux ‘w’ command

command-line-interfacelinuxUtilities

I'm trying to figure out a process that monitors users sessions on a remote server and alerts them when they are being idle too long, which with the Linux command w is aptly appropriate.

Problem is – w uses 3 different formats to specify the idle time of the session, and I can't figure them out properly. An output of w might look like this:

 11:40:57 up 400 days, 10:46, 13 users,  load average: 5.07, 5.10, 4.83
USER     TTY      FROM           LOGIN@   IDLE   JCPU   PCPU WHAT
john     pts/1    XX.XX.XX.XX   Wed13   22:29m  0.13s  0.04s ssh master-db
june     pts/2    XX.XX.XX.XX   Wed13   46.00s  0.67s  0.13s -bash
jenn     pts/4    XX.XX.XX.XX   11:13   27:47   4.16s  0.11s -bash

As you can see, IDLE has different formats for each of the users:

  • "AA.BBs" obviously means that AA seconds and BB 1/100ths of a second (46 seconds in the case of June) has passed since she was last active on the console.
  • "AA:BBm" probably means that AA hours and BB minutes have passed since John was last active on his session.
  • "AA:BB" is the format I can't figure out – how long has Jennifer not being active in her session?

Best Answer

Without a qualifier, it means MM:SS -- that is, minutes and whole seconds. As an added bonus, there's a fourth format you don't have in that output -- a number of days (NNdays) of inactivity.