4

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?

7

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.

0

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 Mar 14 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.