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.
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.
Both "last" and "last reboot" return the same disappointing result for me. The man page was no help.
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.
I verified that /var/run/utmpx exists. Then my eyes glazed over and I fell into a coma.
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.
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.
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.
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?
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.
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.
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.
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.
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?
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.
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.
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!
You could run the command as a shell script. Create a file called reboot-log.sh and put this in it:
last reboot >> ~/Desktop/reboot-log.txt
Then, from Terminal, run chmod +x on reboot-log.sh 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.
Is there a PDF of everything one can do in Terminal?
John, there are entire books that have been written about everything you can do in Terminal. :-)