Skip to content

Instantly share code, notes, and snippets.

@Catoverflow
Created September 5, 2024 21:43
Show Gist options
  • Save Catoverflow/cb38f4c9653ae25753ea855410177e87 to your computer and use it in GitHub Desktop.
Save Catoverflow/cb38f4c9653ae25753ea855410177e87 to your computer and use it in GitHub Desktop.
Systemd Service Logging CPU Temperature and Voltage
# 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
#!/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