Skip to content

Instantly share code, notes, and snippets.

Created March 31, 2022 15:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
check the time of the last kernel panic on you mac
import os
import datetime
with os.popen("nvram -p") as out:
ts_line = next((line for line in out.readlines() if line.startswith("panicmedic-timestamps")), None)
if ts_line:
ts_hex = ts_line.split("\t")[-1]
ts_int = int(ts_hex, 16)
ts = datetime.datetime.fromtimestamp(ts_int // 1000000)
print(f"Last kernel panic: {ts}")
print("There's no kernel panic reported in NVRAM.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment