Something similar to linux
cat /proc/uptime
which returns the uptime in seconds, and preferably not parsing uptime(1).
Something similar to linux
cat /proc/uptime
which returns the uptime in seconds, and preferably not parsing uptime(1).
The Uptime article on Wikipedia has an interesting lead:
Using sysctl
There is also a method of using sysctl to call the system's last boot time: $ sysctl kern.boottime kern.boottime: { sec = 1271934886, usec = 667779 } Thu Apr 22 12:14:46 2010
There is a function UpTime
declared in DriverServices.h. I believe this is equivalent to another function mach_absolute_time
. Both seem to be undocumented.
Unfortunately the "sysctl kern.boottime" returns the seconds of the timestamp, not elapsed seconds.. Multiple calls do not increase the second count, but must be seconds from epoc of the boot date itself.