Created
September 5, 2024 21:43
-
-
Save Catoverflow/cb38f4c9653ae25753ea855410177e87 to your computer and use it in GitHub Desktop.
Systemd Service Logging CPU Temperature and Voltage
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
# in /etc/systemd/system/cpu_log.service | |
[Unit] | |
Description=CPU Temp and Voltage Logging Service | |
[Service] | |
ExecStart=/usr/local/bin/cpu_log.sh | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
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
#!/bin/bash | |
# in /usr/local/bin/cpu_log.sh | |
# You can change the script according to sensors' result | |
while true; do | |
timestamp=$(date '+%Y-%m-%d %H:%M:%S') | |
stat=$(sensors | awk '/Tctl:/ {t=$2} /VIN/ {vins = vins " " $1 $2 $3} END {print t, vins}') | |
echo "$timestamp: $stat" | |
sleep 3 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment