Question

Prevent queued scheduled tasks to run at a certain time

  • 7 March 2022
  • 2 replies
  • 27 views

Badge

Hi!

 

I would like to ensure that no scheduled task could be triggered between 5:00 and 5:30 AM because its the maintenance time of some other servers that interfer with the tasks.

 

I use to set schedule time manually outside of this range but sometimes, for obscur reason, tasks are delayed and put in queued and are triggered during this period and cannot complete successfully.

 

Is it possible to define an exception time range where no task can be triggered at all?

 

Thank you


2 replies

Userlevel 5
Badge +29

If you flip this problem on its head, you could approach it like this....

If the engines are busy, they can't run queued jobs. So you could setup a schedule (one per engine) at 5am that runs a job with a decelerator that takes 30 mins. Set this to the highest priority so it runs before anything else in the queue Then the engines can't be used for other tasks.

 

In saying that, there are some risks I can see with the problem and my proposed solution

  1. What if a triggered (before 5am) job is running during the maintenance period - that could fail if a required resource is down
  2. In the same scenario, your scheduled task will then kick off during that window - could start at 5.25 and therefore finish at 5.55
  • one way around this would be to dynamically set the run time of the decelerator based on when it starts. use a timestamper, calculate how long till 5.30, then use that time in the decelerator. If current time stamp > 5.30 set no delay
  1. This wouldn't stop someone setting a schedule to run during the outage, but would instead add it to the queue and run once the 'blocking' jobs are finished
Userlevel 5
Badge +29

If you flip this problem on its head, you could approach it like this....

If the engines are busy, they can't run queued jobs. So you could setup a schedule (one per engine) at 5am that runs a job with a decelerator that takes 30 mins. Set this to the highest priority so it runs before anything else in the queue Then the engines can't be used for other tasks.

 

In saying that, there are some risks I can see with the problem and my proposed solution

  1. What if a triggered (before 5am) job is running during the maintenance period - that could fail if a required resource is down
  2. In the same scenario, your scheduled task will then kick off during that window - could start at 5.25 and therefore finish at 5.55
  • one way around this would be to dynamically set the run time of the decelerator based on when it starts. use a timestamper, calculate how long till 5.30, then use that time in the decelerator. If current time stamp > 5.30 set no delay
  1. This wouldn't stop someone setting a schedule to run during the outage, but would instead add it to the queue and run once the 'blocking' jobs are finished

potential solution to my first point

set an external (windows task scheduler) schedule to make a call to the rest api to remove all engines during the outage period, then reinstate them once the maintenance window is up

Reply