I am trying to track the occurrences and duration of power outages. I have my computer(Mac High Sierra) powered by a UPS and set to shutdown when there is an outage. I have an applescript that when run prints the time and date to a text file and am able to get that to run on start up. However, I am unable to get it to work when the computer shuts down. I have tried using launchd and logout hooks to no avail. How should I go about this?