First and foremost I want to know how long my laptop (unix, apple, OSX 10.9 mavericks) has been 'awake' (i.e. how long its been open, or since it last 'slept'). I' also be interested in how long since the last restart, and time since the last shutdown (if those two things can be differentiated). I've tried the who and w commands, which seem to show me time for the whole system, and for individual processes (terminals?) since the system last restarted.

Is there a way to tell how long the system has been awake, explicitly?
Does the reported process times include sleep-time (i.e. when my laptop is closed)?
Is there a way to distinguish between restart and shutdown?

2 Answers 2


Use uptime command. Yes, it includes sleep time, if you don't want to include it see:

There is no way to distinguish between restart and shutdown, without parsing logs.


For scripts:

test $(cut -d '.' -f1 /proc/uptime) -gt 60

This will determine if system booted more than 60 seconds ago.

  • This unfortunately does not answer the question. Also note that macOS lacks the /proc file hierarchy.
    – Kusalananda
    Commented Mar 14, 2019 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .