Skip to content

Instantly share code, notes, and snippets.

@somada141
Last active August 29, 2015 14:15
Show Gist options
  • Save somada141/6cf27716af55a679a617 to your computer and use it in GitHub Desktop.
Save somada141/6cf27716af55a679a617 to your computer and use it in GitHub Desktop.
Get uptime on mac #python #system #shell

Using the following terminal command one can retrieve the uptime in seconds:

sysctl kern.boottime

getting a response like this:

kern.boottime: { sec = 1362633455, usec = 0 } Wed Mar  6 21:17:35 2013

Using cut one can retrieve the amount of seconds:

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

getting a response like this:

1362633455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment