Skip to content

Instantly share code, notes, and snippets.

@WendySanarwanto
Created November 12, 2017 11:41
Show Gist options
  • Save WendySanarwanto/e239c2e9c20b794eb66f8bfd045f2b31 to your computer and use it in GitHub Desktop.
Save WendySanarwanto/e239c2e9c20b794eb66f8bfd045f2b31 to your computer and use it in GitHub Desktop.
Bash script for displaying CPU's current temperature & speed of all of its cores, on Banana Pi M3
#!/bin/bash
# Instructions:
# -------------
# 1. Save this script into an `.sh` file (e.g. cpuinfo.sh).
# 2. Make the `.sh` file to be executable by running `chmod` command. Example: chmod 755 cpuinfo.sh
# 3. Optionally, you could create a symbolic link to the `.sh` file. Example: ln -s cpuinfo.sh cpuinfo
# 4. An example of running the script on CLI terminal: `./cpuinfo.sh` or `./cpuinfo` if you created a symbolic link in prior step.
# 5. You can use `watch` command, in case you want to show the output of the script & refreshed periodically for each 2 seconds, 5 seconds, etc.
# Example: `watch -n 2 ./cpuinfo.sh` or `watch -n 2 ./cpuinfo`
echo 'CPU Info'
echo '----------'
echo 'Temperature: '$(cat /sys/class/thermal/thermal_zone0/temp) '°C'
for i in {0..7}
do
echo "CPU-$i Frequency: "$((`sudo cat /sys/devices/system/cpu/cpu$i/cpufreq/cpuinfo_cur_freq` /1000)) ' Mhz'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment