What constitutes "activity" for the purposes of the Unix "who" command? We're trying to find idle sessions but have disagreements as to the precise meaning of the activity in this context. One person contends that the activity time is only reset by user input--that is, data coming into the session from standard input. Others are saying any CPU activity. An authoritative answer would be useful.
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT jferland pts/2 jferland:S.1 10:35 2.00s 0.18s 0.18s /bin/bash jferland pts/3 jferland:S.2 10:35 45.00s 0.18s 0.00s sleep 30 jferland pts/1 jferland:S.0 10:35 0.00s 0.21s 0.00s w
S.0: The one I'm checking on, so definitely 0 time there.
S.1: I left a shell open. Two seconds before I pressed a key without pressing enter. So, any input received works even without a line return.
S.2: I ran
while true; do echo "foo"; sleep 30; done. I even typed a character in the middle of it. Since the input was blocked (never read), I still appear idle there.
Idle time is reset when a character is read from the terminal input. Blocked input doesn't update idle time even if it does affect the screen display. Applications may update under different rules. For example, I used
write which reads input by line, so it only updated my idle time upon pressing enter. The same was true for
perl (literally executed as
perl with no arguments).
Processes run all the time, and it doesnt matter for idle time.
If you do a:
while true; do w; sleep 0.1; done
in one terminal, and open another terminal, you will see that idle time of that other session is reset to zero, only when user inputs something (presses a key). If you run:
while true; do ls; done
in the other terminal the idle time will continue to rise.
So only when the session reads user input, the idle timer is reset.