Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have multiple users that are assigned MacBook Pro's who we know never take them away from their desks. We need some sort of proof to repurpose this hardware and issue them an iMac. We would really like a terminal command we can send or a script we could run to determine the last time the laptop was unplugged.

So far everything we've found just tells you its current state, but not "timer"?

share|improve this question
up vote 8 down vote accepted

You might be able to use ioreg to determine the cycle count of the battery. A low cycle count indicates that the battery has not been discharged and charged very much.

ioreg -l | grep Capacity

"Cycle Count" shows how many times the battery has been cycled. You can read more about battery cycle counts here.

Another idea is to use pmset to log the state of the system's power. You could, in theory, have that dump to a file to investigate after some time has passed.

Take a look at the man page for pmset.

pmset -g pslog will log the state of system's power. As the device is unplugged or plugged you'll see the log update. This could show how frequently a notebook is unplugged and charged. If it remains plugged in for long spans of time, or is often drawing from 'AC Power' then you'd know if it's mobile or not.

share|improve this answer
Thank you! I knew the ioreg command, but haven't seen the pmset one. We'll give that a shot! – Rosko Jan 10 '13 at 17:32

pmset -g rawlog

will show battery details

share|improve this answer
Welcome to Stack Exchange! Can you please expand on what kind of details that command shows? – Kevin Chen Jan 17 '13 at 2:39
Excellent, this is the answer I was looking for -- here is some sample output: 01/01/15 15:55:34 No AC; Not Charging; 95%; Cap=4545: FCC=4782; Design=5770; Time=3:44; -1217mA; Cycles=450/1000; Location=0; Polled boot=12/31/14 01:49:55; Full=01/01/15 15:55:34; User visible=01/01/15 15:54:34 – Matt Jan 1 '15 at 20:56

I had a similar dilemma and I actually greped the syslog for the magsafeStateChanged event... worked like a charm. In the terminal:

syslog | grep magsafeStateChanged

It should return:

Jun 17 03:39:19 computername loginwindow[43] <Notice>: magsafeStateChanged state changed old 2 new 1

Your milage my vary, but for me state 2 is unplugged and state 1 is plugged in. (I determined this by tailing syslog while unplugging the device.)

share|improve this answer

I'll third the suggestion of pmset's logs, however an easier way to access that log (tested under 10.8) is to open System Information, go down to the Software section, pick the Logs subsection and you should see "Power Management logs". Hope this helps!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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