The question is simple: do time periods when computer is in any of the states below count towards total uptime of a system ?
- hibernation
- suspending the system
- changing runlevel
NOTE:
- I am not interested in the
uptime
command itself. Quick look at source code link that Terrance provided reveals nothing about hibernation or suspending - I am interested in how does kernel compute the time system has been running, how does suspending/hibernating affect that value.
- If possible, please provide a reference to documentation
The
uptime
command gets its data from/proc/uptime
, which is exposed entirely by the kernel. So, we'll check out the kernel documentation to see what this actually represents.In
Documentation/filesystems/proc.txt
, we see:(there are two values in this file, hence the two descriptions)
The reference to "wall clock" is important here - it means all elapsed time, regardless of whether or not the machine's clocks are running. So, this time will keep increasing in suspended or hibernated state.
Putting it another way, the uptime value is effectively the time elapsed since the last boot.
The
uptime
is grossly misleading. If you useuptime -s
it is more meaningful:Now you can see it simply shows you the last boot time. If you want to know the real uptime see this answer. Sample output: