run script in time and date range

i need to run one script inside of other, and there is some terms

  • main script in scheduled in cron for everyday runing every 5min
  • i need to run /tmp/script2.sh after first 3 days in month
  • i need to run /tmp/script2.sh from 7-9AM, main script is runining all day

all recommendations are welcome, specially if you have better solution then my

#! /bin/sh

TODAY=`date +%e`
HOUR=`date +%l`

/tmp/script1.sh

if [ $TODAY != 1 ] && [ $TODAY != 2 ] && [ $TODAY != 3 ]; 
 then
    if [ $HOUR = 7 ] && [ $HOUR = 8 ] && [ $HOUR = 9 ]; 
     /tmp/script2.sh
    fi
fi

%l is hour 1..12 so script2.sh would run between 7am-9am AND 7pm..9pm

You could try:

#! /bin/sh
 
TODAY=`date +%e`
HOUR=`date +%k`
 
/tmp/script1.sh
 
[ $TODAY -gt 3 ] && [ $HOUR -gt 6 ] && [ $HOUR -lt 10 ] && /tmp/script2.sh