3

Is there a way I can parse a log in OS X to determine the total time the computer has been in use? By "in use", I mean logged in and not in sleep mode.

If there is no such pre-existing log, is there software I can install or even a script I can modify to log this data for me?

1

Do you mean that you want to know the length of time of the current login session, or the total use for the machine since it left the factory?

The latter is not possible because the logs that store that sort of information rotate. The former is sort of possible, but will take you checking the logs frequently. For one, the last command will show recent login sessions.

I don't think any of those options will strip out sleep time, so that would take a lot more effort where you'd have to write a log parser that looked for sleep/wake events and took that time out of the appropriate login session.

It's not something there is a simple solution for.

If you want to keep track of logins and logout you would be better off writing a loginhook and logouthook to log to your own file.

You must log in to answer this question.

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