#!/bin/bash file=~/data/saa [ -f $file ] || exit mtime=`stat -c%Y $file` time=`date +%s` if [ $time -gt $(($mtime+600)) ]; then temp=$(temperature) echo $temp > $file echo $temp else cat $file fi