Skip to content

Instantly share code, notes, and snippets.

@t-chab
Created November 18, 2014 05:54
Show Gist options
  • Save t-chab/c9c56295687c0a4abc7a to your computer and use it in GitHub Desktop.
Save t-chab/c9c56295687c0a4abc7a to your computer and use it in GitHub Desktop.
Shell script which log temperature to a temp file
#!/usr/bin/env sh
# sensors, hddtemp and nvidia-smi commands should be in path
CORE0_TEMP=$(sensors | grep 'Core 0' | awk -F':' '{print $2}' | awk -F'(' '{print $1}' |tr -d ' +')
CORE1_TEMP=$(sensors | grep 'Core 1' | awk -F':' '{print $2}' | awk -F'(' '{print $1}' |tr -d ' +')
HDD_TEMP=$(hddtemp /dev/sdb |awk '{ print $3}')
GPU_TEMP=$(nvidia-smi -a |grep "GPU Current Temp" |awk '{ print $5}')
OUT_FILE=/tmp/$(date +%Y-%m-%d).temp.log
DATETIME=$(date +"%Y-%m-%d %T")
echo "$DATETIME; $CORE0_TEMP; $CORE1_TEMP; $HDD_TEMP; $GPU_TEMP°C;" >> $OUT_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment