Battery Capacity Logger
I just replaced the battery in the 2005 ibook G4 today, great to return to the days of 4 hours of use. I decided I'd like to monitor the life of the battery and so wrote a quick cron job script to log the battery capacity every day. I also have installed this on my main laptop which still gives me 3 hours after 18 months of use.
Write the script.
#!/bin/sh# batterylogger.sh : Log battery capacity to a file#date >> ~/batteryCapacityLog.logsystem_profiler SPPowerDataType | grep "charge capacity" >> ~/batteryCapacityLog.log
Make it executable and put somewhere sensible.
chmod 755 batterylogger.shcp batterylogger.sh /usr/local/bin/
Make sure it is activated daily by adding the following line in crontab using crontab -e which will make it run at 5:10am every day. This time is chosen to not clash with other actions executing should my laptop be awake at 5am and also to ensure it run each morning when I wake the laptop up.
10 5 * * * /usr/local/bin/batterylogger.sh
The format looks like the following:
Wed Nov 11 20:03:26 GMT 2009Full charge capacity (mAh): 4859
I may improve the format in the future and add some nice "gnuplot" plots but this gives me the info I want right now. For the record, the outgoing battery was showing a capacity of around 350mAh. This translates to roughly 10-15 mins of use. OS X 10.5.8