我想知道的是这个。我得到气压读数,我想创建一个警报。我有一个工作,但我想添加一个时间比较更准确。 例如," X"数字低于" X"数字,然后说5分钟,然后做点什么。
感谢收听。
答案 0 :(得分:1)
您可以执行以下操作:
#!/bin/bash
while [ 0 ]
do
oldval=`cat reading` # Suppose that reading is the file where readings are updated
sleep 5m # sleeps for 5 minutes
newval=`cat reading`
if (( $newval < $oldval-5 ))
then
echo "$( date ) : Beep Beep " | tee -a barrolog
#above steps prints the output as well as append it to a log file
else
echo "$( date ) : No change " | tee -a barrolog
fi
done
# The script never reaches this point.
脚本检查相对于前一个的读数。您可能希望将读数与固定值进行比较。