/proc/uptime in Mac OS X

Ryan picture Ryan · Mar 11, 2013 · Viewed 7.8k times · Source

I need the EXACT same output as Linux's "cat /proc/uptime".

For example, with /proc/uptime, you'd get

1884371.64 38646169.12

but with any Mac alternative, like "uptime", you'd get

20:25 up 20:26, 6 users, load averages: 3.19 2.82 2.76

I need it to be exactly like cat /proc/uptime, but on Mac OS X.

Answer

Ryan picture Ryan · Mar 14, 2013

Got it...

$sysctl -n kern.boottime | cut -c14-18
87988

Then I just converted that to readable format (don't remember how):

1 Days 00:26:28