Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use ioreg command to get battery cycle count UNIX
Apparently, since the OS X 10.3.8 update, the ioreg command now also shows battery cycle count on Apple laptops. By issuing the following command...
ioreg -l | grep Capacity
...the cycle count information is displayed among the other known battery information. For my band new Powerbook battery, the cycle count stands at 10. Your mileage may vary...

[robg adds: A previous hint goes into great detail on ioreg, and includes a script for checking some of its values. On my machine, the output of the above command is as shown below. It takes a few seconds to run, given the length of the output from ioreg -l (try it sometime!).
$ ioreg -l | grep Capacity
    | | |   "IOBatteryInfo" = ({"Capacity"=3971,"Amperage"=0,
            "Cycle Count"=43,"Current"=3962,"Voltage"=12493,
            "Flags"=838860805,"AbsoluteMaxCapacity"=4200})
    | |   |   |     "IOBatteryInfo" = ({"Capacity"=3971,
                    "Amperage"=0,"Cycle Count"=43,"Current"=3962,
                    "Voltage"=12493,"Flags"=838860805,
                    "AbsoluteMaxCapacity"=4200})
Note that I have wrapped the lines by hand -- they're actually really wide single lines. If you don't set your Terminal window *really* wide, though, you won't see all the output; it gets chopped with a $ symbol. Is there a "wrap" option on grep that I'm not aware of?]
    •    
  • Currently 2.83 / 5
  You rated: 2 / 5 (6 votes cast)
 
[47,827 views]  

Use ioreg command to get battery cycle count | 33 comments | Create New Account
Click here to return to the 'Use ioreg command to get battery cycle count' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use ioreg command to get battery cycle count
Authored by: macjools on Feb 16, '05 10:40:22AM
you need to specift the clip width for ioreg with ioreg -w0 -l (from man ioreg)
-w Clip the output to the specified line width. The default width value is the current screen size. A value of 0 specifies an unlimited line width.


[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: clamstrip on Feb 17, '05 04:20:03PM

...or, recalling the unix command 'fmt'

ioreg -l | grep Capacity | fmt

or

ioreg -l | fmt | grep Capacity



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: jacobolus on Dec 13, '05 12:03:21AM

No, this way doesn't work, because it's ioreg that is clipping the content, not grep. Running it through fmt does nothing to bring back content that has already been lost.



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: seanhussey on Feb 16, '05 11:01:51AM

So, what does this mean, exactly? My cycle count is 196. Is my battery getting on in years, or is that really good?



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: hrbrmstr on Feb 16, '05 12:19:32PM

http://www.buchmann.ca/Chap10-page7.asp

has some info on this.

i'm not sure what is or isn't good for apple laptops (since the cycle count # meaning will be different for each batch of batteries).




---
Mind the gap...



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: hrbrmstr on Feb 16, '05 12:25:43PM

http://www.macosxhints.com/article.php?story=20030314081843218

(our own Mac OS X Hints site!) has some *really* good info as well.

---
Mind the gap...



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: styrafome on Feb 16, '05 01:22:08PM

This article is more specific than the others posted. It says the lifetime of a lithiumi-ion battery is in the range of 300-500 cycles.
http://www.batteryuniversity.com/parttwo-34.htm



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: zojas on Feb 16, '05 01:45:01PM

interesting, my ibook's battery has a Cycle Count of 865. my Capacity is down to 2858, which is still decent considering its age. (the capacity used to be as high as 3530)



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: Thiery on Feb 16, '05 11:31:57AM

There is a small utility which gives practically the same number of
elements as this command : Battorox (freeware) : http://www.branox.com/Battorox/Battorox.html
This small software must be based on this quite practical command.
Afflicted for my English, but I am French.



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: styrafome on Feb 16, '05 01:33:20PM

Battorox may be doing something different, because it doesn't indicate the cycle count, which is the entire point of this hint.



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: Thiery on Feb 16, '05 04:33:46PM

Last version 1.7.8 indicates the cycle count now



[ Reply to This | # ]
Turning on line wrapping in Terminal
Authored by: babbage on Feb 16, '05 11:41:39AM

Rob wrote...

Note that I have wrapped the lines by hand -- they're actually really wide single lines. If you don't set your Terminal window *really* wide, though, you won't see all the output; it gets chopped with a $ symbol. Is there a "wrap" option on grep that I'm not aware of?

You can change this behavior in Terminal itself. Click on the Terminal menu item, then Window Settings..., and a dialog window will pop up. In the dropdown widget at the top of the window, select Buffer, then in the Scrollback section check the box next to Wrap lines that are too long. While you're here, you may also want to check the boxes next to Rewrap lines on window resize and Scroll to bottom on input.

It should possible to get the same result with the defaults command:

defaults write com.apple.Terminal Autowrap YES
defaults write com.apple.Terminal Backwrap YES
defaults write com.apple.Terminal RewrapOnResize YES

Hope this helps!

---
--
DO NOT LEAVE IT IS NOT REAL

[ Reply to This | # ]

Turning on line wrapping in Terminal
Authored by: babbage on Feb 16, '05 11:45:18AM

Oh and, in case it isn't clear, after changing settings for a window in the dialog box, push the Use Settings as Defaults button to make the change permanent for new windows.

This probably won't take effect for other currently open windows, though I haven't tested that yet. New windows will have the new setting, so opening new windows or relaunching Terminal will make the changes available.

The same constraint applies to the defaults command as well -- you'll need to open new windows or restart Terminal for it to work.

---
--
DO NOT LEAVE IT IS NOT REAL

[ Reply to This | # ]

Turning on line wrapping in Terminal
Authored by: chrisale on Feb 16, '05 11:48:24AM

What I like to do if I get a result from a Terminal command that is either really long, or all on one line.. I just "pipe it" to a file.

So, for this command I do:

ioreg -l >> ioreg.txt

Which dumps everything into that text file (in the current directory), then I can read it much more easily, search it, save it ect. Works great for man pages too.



[ Reply to This | # ]
Turning on line wrapping in Terminal
Authored by: chrisale on Feb 16, '05 11:56:18AM

Oh, I wanted to put up my result from ioreg... it's no wonder my battery doesn't hold a charge anymore! My TiBook is showing 100% capacity!

"IOBatteryInfo" = ({"Capacity"=176,"Amperage"=0,"Cycle Count"=299,"Current"=176,"Voltage"=16386,"Flags"=838860805,"AbsoluteMaxCapacity"=3600})

Is there any way to "fool" the computer or the battery into thinking the Capacity is actually somewhre close to the "AbsoluteMax?"



[ Reply to This | # ]
Turning on line wrapping in Terminal
Authored by: Puzo on Feb 16, '05 12:43:39PM

For reference, if anyone is interested, I have this:
"Capacity"=5370
"Amperage"=18446744073709549742 (when power is plugged in, the amperage is 0)
"Cycle Count"=31
"Current"=5203
"Voltage"=12263
"Flags"=4 (when power is plugged in, the flags value is 1090519045)
"AbsoluteMaxCapacity"=5400

(PBook G4 1.5G 17")



[ Reply to This | # ]
Turning on line wrapping in Terminal
Authored by: ephramz on Feb 16, '05 12:18:02PM
Hmm, I have all these settings turned on in my Window Settings/Buffer but ioreg and other commands like ps -ax still spit out lines that are too long, not wrapped, and end with a '$'. I even set these as the default and still no luck. Any ideas?

[ Reply to This | # ]
Turning on line wrapping in Terminal
Authored by: pediddle on Feb 16, '05 01:14:56PM

Use "ioreg -l -w 0" (that's a zero) to disable the stupid truncating with the $.

God only knows why Apple would design a non-interactive program to destroy it's output by default...



[ Reply to This | # ]
Turning on line wrapping in Terminal
Authored by: zojas on Feb 16, '05 01:51:26PM

use 'ps axww' instead, then ps won't truncate its output. (I typically add the 'u' flag too, but I don't remember why)



[ Reply to This | # ]
Turning on line wrapping in Terminal
Authored by: u2mr2os2 on Feb 17, '05 01:30:42AM

I'm amazed that you took the time to write all that about the Terminal settings but didn't bother to test it to find out it doesn't solve the problem.



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: jonn8n on Feb 16, '05 12:48:58PM
I've updated my free and editable Battery Info AppleScript to reflect the new cycle count parameter.

Jon

[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: ahbe on Feb 17, '05 10:00:32PM

Very nice little script. One small suggestion, add a link back to your website below the battery information. I would like to be able to check back for future updates in a simple way. As it is, I just added the URL to your website in the comments section of the Info tab. Anyway, thanx for the great little script. Keep up the good work. =)



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: tpressman on Feb 16, '05 02:36:57PM
The MAC DADDY of all battery status indication apps, scripts or shell scripts is located here:

http://www.mitt-eget.com/software/macosx/#battery

Version 1.3 of the little guy has been updated to work with the changes in ioreg of 10.3.8

I had been using the old 1.1 version of this script and getting terrible results in 10.3.8 and started going down the long road of calibration thinking that would fix things. Now I have lost over 100Ah on my battery calibration due to time contrtaints and have to start over! This script is THE MAC of all battery apps. Just drag the shell script into a terminal window and hit return! Wish I'd seen this hint a day sooner!

[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: ahbe on Feb 17, '05 10:29:16PM
Hmm..... When I run this script, all is well accept for the capactiy. It shows:

Battery: battery installed, above warning level
Charger: charger connected, not charging
UPS: UPS not installed
System: clamshell is closed, clamshell was closed on wake up
Voltage: 12.534V
Current: 0.000A
Charge: 2.778Ah of 2.923Ah (95.0%)
Capacity: 2.923Ah of 4.200Ah (69.6%)
Cycles: 108

Only 69.6% capacity even though I'm effectivly fully charged? I thought I had noticed a decrease in battery time. This first gen 12" PB is starting to show her age...

[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: ahbe on Feb 17, '05 10:47:05PM

OK, I'll reply to my own post. So I've been running my PB for a while off the battery now, and I'm down to 74% charge, however the capacaty has stayed constant at 69.6%. So what gives? Am I understanding this wrong? Is there a way to fix this? Will a calibration perhaps get me back up to near 100% again? Thanx in advance.



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: Anonymous on Feb 18, '05 02:31:38PM

Capacity isn't charge. Capacity is how much your battery-when-full compares to a brand new battery. Note that when you were at 95%, your capacity was being compared at 2.923Ah against a brand new battery's charge of 4.200Ah. And, no, most likely a calibration will not get you up near 100%. Although there are things you can Google for and look on the site here for with regards to trying to wring more life out of your battery, the more recharging cycles you go through, the more you lose capacity, until you eventually have to purchase a replacement battery.



[ Reply to This | # ]
above max capacity
Authored by: lebnjay on Feb 16, '05 03:23:11PM

wow, on my new 12" powerbook I get this

"IOBatteryInfo" = ({"Capacity"=4555,"Amperage"=18446744073709550267,
"CycleCount"=6,"Current"=4150,"Voltage"=11835,
"Flags"=4,"AbsoluteMaxCapacity"=4400})

showing a capacity greater than the AbsoluteMaxCapacity. Not sure how that can be.

also it only shows a cycle count of 6, I have had this powerbook since Saturday and and thought I had gone through more cycles than that.
-lebn



[ Reply to This | # ]
above max capacity
Authored by: legacyb4 on Jul 16, '05 01:27:47AM

In contrast, my wife's Pismo from 2000 still on the same battery reads:

| | | | "IOBatteryInfo" = ({"Capacity"=10000,"Amperage"=0,"Cycle Count"=756,"Current"=0,"Voltage"=0,"Flags"=32,"AbsoluteMaxCapacity"=4800},{"Capacity"=546,"Amperage"=18446744073709550163,"Cycle Count"=756,"Current"=2,"Voltage"=10946,"Flags"=148,"AbsoluteMaxCapacity"=4800})

Capacity=10000 sounds a bit off though so I'm running the battery down to see if it changes any stats. I've been on 0% for the last 20 minutes or so without any ill effect.



[ Reply to This | # ]
Easy way to avoid cutoff
Authored by: viscaria on Feb 16, '05 06:04:58PM
ioreg -l | grep Capacity | less

[ Reply to This | # ]
Easy way to avoid cutoff
Authored by: viscaria on Feb 16, '05 06:17:11PM

err, nevermind. I spoke too soon.



[ Reply to This | # ]
quick & dirty line width soln. maybe
Authored by: gxw on Feb 16, '05 09:25:24PM

ioreg -l -w300 > huh.txt ; open huh.txt

pipe the output to a file then open the file in the textEdit.
Just discovered that there is no sideways scrolling in textedit <boggle?!?>
Wouldn't recommend the -w0 option for this method.



[ Reply to This | # ]
Use ioreg command to get battery cycle count
Authored by: Whosawhatsis on Feb 17, '05 03:03:32AM
I noticed this a couple of days ago. It broke the script that I was using to monitor my battery with Geektool. It's been updated, but did they really have to put a space in "Cycle Count"? "AbsoluteMaxCapacity" doesn't have any...

Geektool is great for monitoring this type of information. If anyone's interested, all of my scripts for it are posted in the geektool forum.

---
I was offered a penny for my thoughts, so I gave my two cents... I got ripped off.

[ Reply to This | # ]

Use ioreg command to get battery cycle count
Authored by: anuflora on Feb 15, '11 06:20:52AM

Hi all,

Is there any software tool/script/command to find energy consumption by LCD and Wireless Interface? Someting like powertutor for Android.

Thanks & Best Regards,



[ Reply to This | # ]