Check data and time

I am attempting to figure out how to do a time check within my script.
For some reason I can not seem to get this to work correctly.

I want the script to first see if it is Saturday.
If it is Saturday then check to see if it's between the time 5:30am and 6:30am.
If it is between 5:30am and 6:30am then exit out of the script.
If it is not between 5:30am and 6:30am then let the script continue.

I just need this script to exit out if it is Saturday between the hours of 5:30am and 6:30am.
I know there are better ways of doing this but I am trying to figure out why the script below is not working.

Thanks for the help.

#!/bin/sh
day=`date`
time=`echo $day | cut -d" " -f4`
hour=`echo $time | cut -d":" -f1`
minute=`echo $time | cut -d":" -f2`
dayname=`echo $day | cut -d" " -f1`

        if [ $dayname = 'Sat' -a $hour = 5 -a $minute -gt 15 ]
        then
                if [ $dayname = 'Sat' -a $hour = 6 -a $minute -lt 50 ]
                then
               # Between Sat 5:15 and 6:30, do not continue.
                exit
                fi
        fi
echo "Not between Sat 5:15 and 6:50.... Continue script..."

Hi.

DAY=$(date '+%w')
TIME=$(date '+%H%M')

[ $DAY -eq 6 -a $TIME -gt 530 -a $TIME -lt 630 ] && exit

echo It's not Saturday between 05:30 and 06:30, so continue...

Your post said 05:30 and 06:30, but your sample code said 05:15 and 06:50?

  1. Numeric comparison what you are doing is wrong.. You can use, -eq, -ge, -le.

For this requirement, the following works,

#!/bin/sh
day=`date`
time=`echo $day | cut -d" " -f4`
hour=`echo $time | cut -d":" -f1`
minute=`echo $time | cut -d":" -f2`
dayname=`echo $day | cut -d" " -f1`

        if [ $dayname = 'Sat' -a $hour -ge 5 -a $minute -gt 15 ]
        then
                if [ $dayname = 'Sat' -a $hour -le 6 -a $minute -lt 50 ]
                then
            echo "its that time..";
               # Between Sat 5:15 and 6:30, do not continue.
                exit
                fi
        fi
echo "Not between Sat 5:15 and 6:50.... Continue script..."
#!/bin/sh
DATE=`date +%u%H%M`
[ $DATE -gt 6515 -a $DATE -lt 6650 ] && exit 0;
......
# Do something else ...

Thanks!