Tricky scheduling problem

Hi

I was wondering if someone can assist me with this complicated scheduling config.

I need to restrict the WAN interface bandwidth to 512k between 7:00 am to 3:30 pm every weekday.
After 3:30 pm I open up the bandwidth to 10Mb until 7:00 am the next day, every weekday.

On the weekends the bandwidth is opened up to 10Mb.

I have got this part working pretty well with a morning schedule and an afternoon schedule running every M,T,W,T,F. (I´m sure there is a better way to do this as well).

The only problem is that we have long power cuts where we live and if the power returns, say after 3:30 pm the router bandwidth will continue to be restricted until 7:00 am the next day. This is worse still on Fridays if the afternoon script fails to run during a powercut, the bandwidth could potentially be limited for the entire weekend.

Is there a way for a script to first check if the current time and day and then run the script accordingly?

Thanks very much for any pointers.

NTP on routerboard are set?

The routerboard have right time after boot?

Hi rextended

Sorry, should have mentioned this.

Yes, NTP is set and the router always gets the correct time from local NTP servers.

Use one global variables to check every x minutes if the profile are set accordingly current date and time.

If not set, run appropriate script.

Inside each script set global variables accordingly.