Monitoring CPU tempreture and Fan speed through Shell Scripting

First we need to install lm-sensors (Linux Monitroing Sensors) tool. The lm-sensors provides tools and drivers for monitoring temperature, voltage, humidity and fans speed. First start terminal and update the repository

sudo apt-get update

now Install lm-sensors

sudo apt-get install lm-sensors

after the completion of installation type following command in terminal

sudo sensors-detect

after that run following command

sudo service kmod start

It will ask you few questions, Answer 'Yes' for all of them. Finally to get your CPU temperature type sensors in your terminal.

sensors

Now here is the simple shell script which prints the CPU temperature and Fan Speed.
 #!/bin/bash  
 # Shows the cpu tempreture and Fan speed  
 #  
 while ((1))  
 do  
      clear  
      echo "CPU Tempreture : "  
      echo "==========================================================|"  
      sensors | egrep "Core|fan"  
      echo "==========================================================|"  
      sleep 2  
 done  

the output of script   ./cpu.sh


Thanks...!! (*_*)