Last active
February 19, 2019 06:49
-
-
Save tonghuikang/96168358d4842219ac30984c7a251f29 to your computer and use it in GitHub Desktop.
record battery information daily
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create script | |
touch power_history.sh | |
sudo echo ' | |
# create file if not exist | |
touch ~/power_history.txt | |
# create separating header | |
echo Power Information Recorded >> ~/power_history.txt | |
# record unix time in seconds | |
echo $(date +%s) >> ~/power_history.txt | |
# record date for easier reference | |
echo $(date) >> ~/power_history.txt | |
# record power info | |
echo "`system_profiler SPPowerDataType`" >> ~/power_history.txt | |
' >> ~/power_history.sh | |
# give permission to the script to read and execute | |
sudo chmod 500 ./power_history.sh | |
# run the script every day | |
touch ~/.crontab | |
echo 0 14 \* \* \* /Users/$(id -un)/power_history.sh >> ~/.crontab | |
sudo crontab -u $(id -un) ~/.crontab # this may only work on Terminal not iTerm2 (if you know what this is) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment