Thoughtful, detailed coverage of the Mac, iPhone, and iPad, plus the TidBITS Content Network for Apple consultants.

Exploring Your Mac’s Restarts via the Command Line

Curious to know when you last had to restart your Mac, or how often you’ve been rebooting? It turns out that there’s a command line invocation to report on that information. What’s the utility of such details? If you’re troubleshooting flaky hardware, perhaps you want to document how often you’re having to restart, or you might want to look up the exact date of a recent kernel panic when working with tech support.

If you’re intimidated by Unix, don’t worry, as this one is as simple as it gets. Open Terminal from /Applications/Utilities, and type last reboot and press Return. You’re presented with a log of all the times you restarted your Mac, back to when the log begins. Mine dates only to October 2013, whereas Adam Engst’s includes 70 restarts since May 2013, and shows several instances when he was restarting repeatedly while trying to isolate a bad DIMM.

Technically, the last command displays the sessions of specified users, so you could also type last shortname — where shortname is the short name of a user account — to see all the times that particular account logged in, or just last by itself to show all sessions. reboot is a pseudo-user, as is shutdown, so last shutdown displays all the logged shutdown events.

Want to create a permanent record of your restarts? Try this command:

last reboot > ~/Desktop/reboot-log.txt

That tells your Mac to run the last reboot command, and then send its output to a new file called reboot-log.txt on your Desktop. And if you wanted to keep recording restarts to this file from the command line, you would instead use:

last reboot >> ~/Desktop/reboot-log.txt

That’s the same command, but with two angle brackets, which specify that the output should be appended to the end of the existing file, instead of overwriting the one that’s already there. Give it a try to see what it does.

While on the subject, as long as you’re in Terminal, try the uptime command to see how long your computer has been running since the last restart.


Check out the Take Control ebooks that expand on the topic in this article:

Release your inner geek and harness the power of the Unix underpinnings to Mac OS X! This 167-page ebook from Joe Kissell explains everything you need to know to become comfortable working on the command line in Terminal, and provides numerous “recipes” for performing useful tasks.


READERS LIKE YOU! Support TidBITS by becoming a member today!
Check out the perks at <>
Special thanks to Gerald Cederquist, Kerry Hughes, Sarah Peters, and
Harvey Barnett for their generous support!

Comments about Exploring Your Mac’s Restarts via the Command Line
(Comments are closed.)  2014-02-17 15:27
There must be more to the "last reboot" command than the article states. I tried it on an iMac running Mavericks and a mini running Leopard. all I get is something like "wtmp begins Mon Feb 17 15:24". Nothing else.
David Weintraub  2014-02-17 16:01
Try just typing "last" and see what it gives you. Also try "man last" which fully describes the command and all of it's options.  2014-02-17 16:12
Both "last" and "last reboot" return the same disappointing result for me. The man page was no help.
Adam Engst  An apple icon for a TidBITS Staffer 2014-02-17 16:35
Interesting. From what I understand, these commands are extracting information from your console log, so if you have something that deletes logs regularly, that might explain it. wtmp was the old place this information was maintained before 10.5. Use man to look at the old wtmp and new utmpx for more details.  2014-02-17 17:02
I verified that /var/run/utmpx exists. Then my eyes glazed over and I fell into a coma.  2014-02-17 17:23
UPDATE: on my mini running Leopard, "last reboot" does nothing useful, but "last | grep reboot" works. But this does NOT work on my Mavericks iMac. Strange.  2014-02-20 17:17
ANOTHER UPDATE: I decided to Restart just to see if anything shook loose. After the Restart "last reboot" showed a record for that Restart only. Before that, my uptime had been about three weeks.
David Weintraub  2014-02-17 16:12
It'd be interesting if you could have it append to specific logs when the system boots or shutdown. On Linux, you'd do it by adding a short startup script and shutdown script under /etc/init.d and /etc/rc3.d. However, the Mac, you need to work with launchd which is a bit more involved.
Kevin Patfield  An apple icon for a TidBITS Contributor 2014-02-17 21:43
In my case I got the essentially empty result (like several others) running in my default [non-admin] account but a list going back to November when I ran from an admin account. Presumably the cutoff is when the OS was last installed/updated. Was Adam using a machine not updated to Mavericks?
Adam Engst  An apple icon for a TidBITS Staffer 2014-02-18 07:36
Yep, that must be it. On my Mac Pro still running Mountain Lion, I go back to May, but on my MacBook Air running Mavericks, my log stops at October. So installing a new version of Mac OS X must clear the log.
Simon  An apple icon for a TidBITS Contributor 2014-02-18 04:40
last reboot >> ~/Desktop/reboot-log.txt

What is this supposed to achieve? Every time it's run it will append the entire history to a file that contains the previous history. You'll end up with tons of duplicate lines if you run this command a lot. It's not as if >> magically only adds new lines to the file.
Adam Engst  An apple icon for a TidBITS Staffer 2014-02-18 07:38
Yeah, I considered taking that out when editing, but decided that it was mostly just a general Unix tip, even if it wouldn't necessarily be all that useful in this particular context.
Phil Gaskill  2014-02-18 06:05
Is there a way to get this to run automatically? I know how to add Terminal to my Login Items, of course, but I don't know how to get it to run a command. Please forgive my iggerance.
Adam Engst  An apple icon for a TidBITS Staffer 2014-02-18 07:40
I'm sure you could do it via Automator, which can encapsulate a shell script in a Mac application, or even with Keyboard Maestro, but why would you want to run it automatically?
Phil Gaskill  2014-02-19 04:19
To automatically maintain a running log without having to manually add each entry. Thanks for the tips, which I should have thought of myself but was having a dumb day.
Adam Engst  An apple icon for a TidBITS Staffer 2014-02-19 08:05
It seems that the logs are maintained except for major OS X upgrades, so you can use last reboot at any time to see the running log without having to do anything else. You might want to make a note to save it out to a file before you upgrade to the next version of OS X, though.
Phil Gaskill  2014-02-19 09:27
Well, I meant "without having to manually add each entry in order to have a continually up-to-date log." Sure, it seems to create a full log back to last OS upgrade when I run the command, but I wouldn't mind being able to just open up that file in Bean and read the most recent entries without having to launch Terminal and run the command first. Call me lazy. Anyway, no biggie. Thanks!
Josh Centers  An apple icon for a TidBITS Staffer 2014-02-19 09:34
You could run the command as a shell script. Create a file called and put this in it:


last reboot >> ~/Desktop/reboot-log.txt

Then, from Terminal, run chmod +x on to make it executable. Double click it, and it should create the file on the Desktop. Then just set that shell script to be one of your login items.
John Ferman  An apple icon for a TidBITS Supporter 2014-02-21 11:54
Is there a PDF of everything one can do in Terminal?
Josh Centers  An apple icon for a TidBITS Staffer 2014-02-21 12:10
John, there are entire books that have been written about everything you can do in Terminal. :-)
Adam Engst  An apple icon for a TidBITS Staffer 2014-02-21 12:43
You might check out our "Take Control of the Mac Command Line with Terminal" ebook.