Skip to content

Instantly share code, notes, and snippets.

@kid1412-net
Last active December 12, 2022 04:07
Show Gist options
  • Save kid1412-net/b10117919b3861e9c7755a6d59f5410c to your computer and use it in GitHub Desktop.
Save kid1412-net/b10117919b3861e9c7755a6d59f5410c to your computer and use it in GitHub Desktop.
Log MBP battery information daily
#!/bin/sh
########################################
# References
########################################
# https://forums.macrumors.com/threads/battery-condition-vs-design-capacity-macbook-m1-air-pro.2276871/
# https://forums.macrumors.com/threads/my-iphone-13-pro-max-battery-capacity-has-went-from-99-to-94-in-a-month.2335878/page-2
# https://webcache.googleusercontent.com/search?q=cache:XEXQX8baQQUJ:https://towardsdatascience.com/a-step-by-step-guide-to-scheduling-tasks-for-your-data-science-project-d7df4531fc41&cd=2&hl=en&ct=clnk&gl=vn&client=safari
# https://stackoverflow.com/questions/25622613/crontab-doesnt-execute-ioreg-on-my-mac
# https://crontab.guru/
# https://superuser.com/questions/126907/how-can-i-get-a-script-to-run-every-day-on-mac-os-x
########################################
# Set cron jobs
#
# crontab -e
# 10 10 * * * /Users/hainguyen/bin/smart_bat.sh
#
# List jobs
#
# crontab -l
#
# Remove jobts
#
# crontab -r
#
########################################
POSTFIX=`date +%F`
# POSTFIX=`date +%s`
OUTPUT_FILENAME="SmartBattery_${POSTFIX}.txt"
OUTPUT_DIR="/Users/hainguyen/SmartBattery/"
# echo $OUTPUT_FILENAME
mkdir -p $OUTPUT_DIR
/usr/sbin/ioreg -w 0 -f -r -c AppleSmartBattery > ${OUTPUT_DIR}/${OUTPUT_FILENAME}
########################################
# Mon Dec 12 07:44:02 +07 2022
########################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment