Tiny Core Linux

Tiny Core Base => CorePlus => Topic started by: malikawan on April 26, 2016, 12:31:30 AM

Title: How to check cpu temperature with script or command
Post by: malikawan on April 26, 2016, 12:31:30 AM
Any way to check cpu temperature with script or command. I am using lm-sensor but it don't detect any sensor. Is there any setting after installing lm-sensor utility
Title: Re: How to check cpu temperature with script or command
Post by: patrikg on April 26, 2016, 12:54:47 AM
How about this.
Not using lmsensor just regular linux commands.
Temp in Celsius with 2 decimals.

Code: (bash) [Select]
echo $'scale=2\n'$(cat /sys/class/thermal/thermal_zone0/temp)/1000 | bc
Title: Re: How to check cpu temperature with script or command
Post by: curaga on April 26, 2016, 01:29:48 AM
Did you install the hwmon extension? Without that, you won't get cpu temp.
Title: Re: How to check cpu temperature with script or command
Post by: malikawan on April 26, 2016, 01:30:32 AM
its not working
cat: /sys/class/thermal/thermal_zone0/temp: No such file or directory
sh: cat:: not found
Title: Re: How to check cpu temperature with script or command
Post by: malikawan on April 26, 2016, 01:31:54 AM
Yes curaga i have install the hwmon extension
Title: Re: How to check cpu temperature with script or command
Post by: Misalf on April 26, 2016, 02:51:40 AM
Quote
Is there any setting after installing lm-sensor utility

Yes, run:
Code: [Select]
sudo sensors-detect

Persistency:
Add  /etc/sysconfig/lm_sensors  to your backup.
Check  /etc/sysconfig/lm_sensors  for what modules are needed.
Load those modules in  /opt/bootlocal.sh .
For example:
Code: [Select]
modprobe coretemp
Title: Re: How to check cpu temperature with script or command
Post by: Misalf on April 26, 2016, 04:53:27 AM
Another attempt:
Code: [Select]
#!/bin/sh
for i in /sys/class/hwmon/hwmon*
do
[ -e "$i"/temp*_label ] && LABEL="$(cat $i/temp*_label)" || LABEL="$(cat $i/name)"
TEMP="$(( $(cat $i/*_input) / 1000 ))"
echo -e "$LABEL: \t$TEMPĀ°C"
done