I've come stuck when I was making sure the hour of the day was not been two times so that the rest of the script could not be executed.
Seems simple enough.
I used the -a to join the two conditions together and it would run if the conditions was t/f ( it is only supposed to run if was t/t).
I read on this forum about using && instead of -a. It now works.
Whats the difference?
Code that doesn't work using the -a, change this to && and it works.
WORK_START_HOUR=8 # 8.00am
WORK_END_HOUR=17 # 5.00pm
CHECK_HOUR=`date +"%H"`
CHECK_HOUR=18
if [ $CHECK_HOUR -ge $WORK_START_HOUR ] -a [ $CHECK_HOUR -le $WORK_END_HOUR ]
then
echo "Hour is in the range of 8 to 17"
else
echo "Hour is in outside the range of 8 to 17"
fi
thanks
brett