在开发板做高低温试验的时候,我习惯与编写一个显示温度的脚本,随时观看,这样可以方便的观察到系统是否重新启动,是否超出温度限制,脚本如下:
#!/bin/bash
while true
do
echo "`date +%T` current temperaturei= `cat /sys/class/thermal/thermal_zone0/temp` runtime = `cat /proc/uptime`" | tee -a ./aa.txt
sleep 10s
done
这样脚本会一致运行,在屏幕终端显示的同时,会将记录保存到aa.txt文件中。如下图
0:15:06 current temperaturei= 53000 runtime = 1013.97 992.96
00:15:07 current temperaturei= 53000 runtime = 1014.99 993.96
00:15:08 current temperaturei= 53000 runtime = 1016.02 994.96
00:15:09 current temperaturei= 53000 runtime = 1017.04 995.96
00:15:10 current temperaturei= 53000 runtime = 1018.06 996.96
00:15:11 current temperaturei= 53000 runtime = 1019.08 997.96
00:15:12 current temperaturei= 53000 runtime = 1020.11 998.96
00:15:13 current temperaturei= 53000 runtime = 1021.13 999.96
00:15:14 current temperaturei= 53000 runtime = 1022.15 1000.96
00:15:15 current temperaturei= 53000 runtime = 1023.17 1001.96
00:15:16 current temperaturei= 53000 runtime = 1024.20 1002.95
00:15:18 current temperaturei= 53000 runtime = 1025.22 1003.95
00:15:19 current temperaturei= 53000 runtime = 1026.24 1004.95
00:15:20 current temperaturei= 53000 runtime = 1027.26 1005.95
00:15:21 current temperaturei= 53000 runtime = 1028.29 1006.95
00:15:22 current temperaturei= 53000 runtime = 1029.31 1007.95
00:15:23 current temperaturei= 53000 runtime = 1030.33 1008.95
00:15:24 current temperaturei= 53000 runtime = 1031.36 1009.94
00:15:25 current temperaturei= 53000 runtime = 1032.39 1010.93
00:15:26 current temperaturei= 53000 runtime = 1033.41 1011.93
00:15:27 current temperaturei= 103000 runtime = 1034.43 1012.93
00:15:28 current temperaturei= 53000 runtime = 1035.46 1013.93
00:15:29 current temperaturei= 53000 runtime = 1036.48 1014.93
00:15:30 current temperaturei= 53000 runtime = 1037.50 1015.93
00:15:31 current temperaturei= 53000 runtime = 1038.52 1016.93
00:15:32 current temperaturei= 53000 runtime = 1039.55 1017.93
诸如此类,另外我还需要查看最高温度和最低温度,用于数据统计,需要如何做呢,见下面的脚本
#!/bin/bash
# print the five word of every lines form aa
array=($(cat aa.txt |awk '{print $4}'))
max=${array[0]}
min=${array[0]}
#echo "max= " $max "min= " $min
for v in "${array[@]}"
do
if(( $v > ${max} ));then
max=$v
fi
if(( $v < ${min} ));then
min=$v
fi
done
echo "The Max value is " $max
echo "The Min value is " $min
执行后如下图:
当然最终的结果根据文件内容显示,怎么样,好用吧。