If you run it in control-M, you should be able to run it in the desired time frame, without of taking care of the start time inside the script
You could just add at the beginning of your script :
And before beginning your maintenance :
and remove that flag at the end of your maintenance
Otherwise, schedule it in Control-M and before starting your maintenance, freeze it / unschedule it temporary until you get finished with your maintenance.
I don't know Control-M but i am almost 100% sure such kind of scheduler has some option or other ways for calendar based schedule or time frame windows definition/exclusion, that would make possible to set up such a schedule constraints in one way or another.
I think you should investigate on Control-M possibilities at first since those sort of tools have been design to achieve exactly this kind of task.
Thanks shell, I was able to accomodate your logic and it did work also. But, here I have one more condition to test a condition ,where I need not required to run this script on every thrid week between sat 23:00 pm hrs to 02:45 am sun. I would realy appriciate, if you could help to acheieve the same.
Considering that a week starts on Sunday and if you have the first day of the month on a Saturday, it is already considered one week, then the Saturday of the third week should be between 15 and 21 of each month.
Having said that, if you do not want to run the script in the third week of the month, here is one possible solution: