Advertisement
jjjesss

cpu_temp_contro.sh

Oct 15th, 2013
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. TIME=5 #seconds
  4. CPU_UP_TH=65
  5. GPU_UP_TH=70
  6. CPU_LOW_TH=55
  7. GPU_LOW_TH=65
  8.  
  9. while :
  10. do
  11.     cpu0=`sysctl hw.sensors.cpu0.temp0 | cut -d= -f 2 | cut -d. -f 1`
  12.     gpu0=`sysctl hw.sensors.itherm0.temp4 | cut -d= -f 2 | cut -d. -f 1`
  13.     apm=`/usr/sbin/apm -P`
  14.  
  15.  
  16.     echo "CPU0: ${cpu0} GPU0: ${gpu0} APM: ${apm}"
  17.  
  18.     if [ ${cpu0} -gt ${CPU_UP_TH} ] || [ ${gpu0} -gt ${GPU_UP_TH} ]; then
  19.         if [ ${apm} == 1 ]; then
  20.            /usr/sbin/apm -C
  21.            echo "apm -C"
  22.         fi
  23.     fi
  24.  
  25.     if [ ${cpu0} -lt ${CPU_LOW_TH} ] || [ ${gpu0} -lt  ${GPU_LOW_TH} ]; then
  26.         if [ ${apm} == 2 ]; then
  27.            /usr/sbin/apm -A
  28.            echo "apm -A"
  29.         fi
  30.     fi
  31.  
  32.     sleep ${TIME}
  33. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement