I am trying to write a small bash script to keep track of my cpu temp for "temp_duration" time period, and print the temperature along with the date and time onto a file. I have used the "istats" command and am able to get the temperature using awk and cut, and initialize it to my variables in the script
Error: temp_monitor.sh: line 15: [: 30.00: integer expression expected
any help would be great, I am a beginner at bash scripting.
#!/bin/baash
#to record temperature of cpu, and print it to file if it exceeds a threshold
val=`istats cpu|awk '{print $3}'| cut -b -2`
time_initial=`date|awk ' {print $4} ' | cut -b 7-`
time_now=0
time_duration=10
max_temp=30.00
diff=0
while [ $diff -lt $time_duration ]
do
time_now=`date|awk ' {print $4} ' | cut -b 7-`
diff=$(($time_now - $time_initial))
date_value=`date`
if [ $val -gt $max_temp ]
then
echo $val
echo “at $date_value”
fi
done