In MacOS the command to emit data about battery status is:
pmset -g batt
If you want to record the battery percentage level in a file at regular intervals, here is how to record the data in a one-liner:
while true; do \ echo "$(date "+%Y-%m-%d %H:%M:%S") " \ "$(pmset -g batt | grep "%" | cut -f 2 | cut -f 1 -d ';')" \ >> battery.txt; \ sleep 60; \ done &
which does fit in a single line in Terminal 😉
Leave a Reply