Skip to content

Instantly share code, notes, and snippets.

@albertobissacco
Created May 13, 2020 10:53
Show Gist options
  • Save albertobissacco/16ae842559b3baabdbbaa17f03b1b85c to your computer and use it in GitHub Desktop.
Save albertobissacco/16ae842559b3baabdbbaa17f03b1b85c to your computer and use it in GitHub Desktop.
Raspberry Pi CPU and GPU Temperature
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))
cpuTemp="${cpuTemp1}.${cpuTempM}"
gpuTemp=$(/opt/vc/bin/vcgencmd measure_temp | cut -c "6-9")
red=`tput setaf 9`
grey=`tput dim`
reset=`tput sgr0`
echo -e "${grey}$(date '+%Y-%m-%d %H:%M:%S')${reset} Temp: CPU: ${red}${cpuTemp}ºC${reset}, GPU: ${red}${gpuTemp}ºC${reset}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment