When was the last time you restarted or shutdown your Mac? In the post-iPhone era, most devices are now powered on almost constantly. For better or for worse, the computing landscape has accommodated this "always on" trend, but you still need to periodically restart your devices—especially your Mac.
If you were ever wondering, Mac OS X's built-in utilities can give you information about your computer's uptime status, recent reboots, and recent shutdowns—and it's pretty easy to access. This data can then be used to help diagnose kernel panic issues, troubleshoot random restarts, handoff to tech support, or just satisfy your curiosity.
Uptime is the amount of time your Mac has been running since it was last powered down or restarted. If your uptime is a large amount of time, congrats, you've got a smooth-running machine that can't be beat. If not, you're probably restarting to free of RAM or fix random glitches that happen.
You can quickly see this information via the System Information utility, which is reminiscent of the Windows Task Manager uptime feature.
Just open up System Information on your Mac. You can find it in Spotlight or Launchpad, open it from your Utilities folder in Applications, or right from the menu bar. For the latter, click on the Apple icon, then press and hold the Option key to change "About This Mac" to "System Information."
Once in System Information, select the Software heading from the left sidebar. The last entry in the right panel, appropriately named "Time since boot," will tell you how long your Mac has been running.
Launch the Terminal app on your Mac using whatever method you're comfortable with: Spotlight, Launchpad, Utilities folder, etc. When your Terminal window pops up, just use the uptime command. Type it out and hit return on your keyboard. That's it.
As you can see above, uptime is the second entry (blue). With this command, you can also see the current system time (red), the number of Terminal windows that are open (yellow), and the system load averages for the last 1, 5, and 15 minutes, which is an indicator of how busy your system's resources are.
Open up Terminal again, if it's not already, and use the last reboot or last shutdown command. Just type them out one by one, then press return on your keyboard. The former logs every time your Mac was rebooted, obviously, and the latter when exactly it was shutdown. These logs have a history from when OS X was first installed on your Mac, which is the date the logs were first created; just check out the "wtmp begins" date at the bottom of the logs.
It should also be noted that the recent restart/shutdown history covers Mac OS X kernel panics—when your system detects a fatal error and shuts down—in addition to power on/off events that you initiated through the software or hardware button.
Finding this information for your Mac is quite simple and potentially very useful for troubleshooting if you're having problems with your computer randomly shutting down.