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..."