Skip to content

Instantly share code, notes, and snippets.

@greg76
Created March 31, 2022 15:18
Show Gist options
  • Save greg76/80ac6d89cd587eb6fb4b6b2865bc8e59 to your computer and use it in GitHub Desktop.
Save greg76/80ac6d89cd587eb6fb4b6b2865bc8e59 to your computer and use it in GitHub Desktop.
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}")
else:
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