Last active
December 13, 2020 21:43
-
-
Save jeffypooo/b7dbfe9349b1f6962299379cdfc48d30 to your computer and use it in GitHub Desktop.
Raspberry Pi - Ubuntu - Get the CPU temperature and core frequency
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 | |
temp=$(</sys/class/thermal/thermal_zone0/temp) | |
freq_hz=$(</sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq) | |
temp_f=`echo "$temp/1000" | bc -l` | |
freq_ghz_f=`echo "$freq_hz/1000000" | bc -l` | |
printf "CPU Temp: %.2f°C\n" $temp_f | |
printf "CPU Freq: %.2fGHz\n" $freq_ghz_f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget to make this executable:
If you want to poll, use
watch
:watch -n 1 "/path/to/script/tempc.sh"