#!/bin/bash
at now +1 minutes -f ./test.sh
logFile="/home/.../testLog.txt"
time1="114000"
time2="153000"
currentTime=`date +"%H%M%S"`
echo "" >> "$logFile"
date >> "$logFile"
echo "$currentTime" >> "$logFile"
echo "" >> "$logFile"
if [[ "$currentTime" < "$time1" || "$currentTime" > "$time2" ]]
then
echo "case1" >> "$logFile"
else
echo "case2" >> "$logFile"
fi
该脚本保存在一个名为test.sh
. 当我在例如下午 5 点执行它时,它会写入case1
我的日志文件。但是对于每个后续at
调用(每分钟发生一次),脚本都会写入case2
我的日志文件。你能解释一下为什么吗?