我的脚本:
currenttime=$(date +%H:%M) if [[ "$currenttime" > "00:00" ]] && [[ "$currenttime" < "01:00" ]]; then ./mailscript1.sh else ./mailscript2.sh fi
在这里我希望它应包括00:00和01:00并应触发mailscript1为true,> =和<=无法正常工作
使用+%s(纪元格式)比较时间,依此类推:
currenttime=$(date +$s) if [[ "$currenttime" -ge "$(date -d "00:00" +%s)" && "$currenttime" -le "$(date -d "01:00" +%s)" ]] then ./mailscript1.sh else ./mailscript2.sh fi
2.1m questions
2.1m answers
60 comments
57.0k users