2

I create a scheduled task that runs every 5 hours and enabled the "Delay task for up to (random delay)" option for 2 hours. A found a few problems with this but before I start making changes I'd like to better understand what is happening versus my expectations.

In the last week this task has been running, during several days, the task ran 5 times per day. That shouldn't happen, right? I want it to run every 5 hours. 5 hours times 5 occurrences gives me 25 hours, right? And that doesn't include the random time (up to 2 hours) that should be added to the "base" of 5 hours. I expected this task to run 3 or 4 times a day.

The Next Run Time displayed in the Task Scheduler list is never correct. It displays what appears to be a randomized start time but the task never runs at that time. The task could run earlier, maybe later than the displayed time.

Is there anyway I can get the true start time before it actually starts? The Last Run Time is correct but I'd like to be able to know when the task will run again for reboots, patching, etc.

Is my understanding of the "base" interval and random delay correct? A task should run after the "base" plus random delay has elapsed, correct? For example, a 4 hour base with 2 hours of random delay should not run 6 times in a day; it will trigger 4 or 5 times per day, correct?

2 Answers 2

3

Your understanding of the random delay is correct, you can find more details in the documentation:

Task Scheduler - get_RandomDelay says:

The specified random delay time is the upper bound for the random interval. The trigger will fire at random during the period specified by the randomDelay parameter, which doesn't begin until the specified start time of the trigger. For example, if the task trigger is set to every seventh day, and the randomDelay parameter is set to P2DT5S (2 day, 5 second time span), then once the seventh day is reached, the trigger will fire once randomly during the next 2 days, 5 seconds.

And MS-TSCH 3.2.5.4.2 SchRpcRegisterTask:

TimeTrigger's RandomDelay: The server MUST choose a delay value randomly and delay starting the task after the time trigger fires by the random delay value. The random delay value MUST be chosen from the interval from zero to RandomDelay, inclusive. If not present, the server MUST NOT delay starting the task.

However, it's possible that a scheduled task configured to run every 5 hours starts 5 times a day, for example:

Base start time: 00:00 + 2 minutes => Started at 00:02
Next: 05:02 + 10 minutes => Started at 05:12
Next: 10:12 + 1 hour => Started at 11:12
Next: 16:12 + 2 hours => Started at 18:12
Next: 23:12 + 45 minutes => started at 23:57

About the Next Run Time: No, with a random delay you can't predict the next run time because the random value is computed just before "starting" the task (then, if the random value is 0 the task is immediately started). This is not documented, consider this as an implementation detail: it may or may not change in future versions.

1

5x5 is 25, right, but... 1st run at 0:00 2nd at 05:00 3rd at 10:00 4th at 15:00 5rd at 20:00 Which would leave even 4 hours for the randomized delay, which is RANDOM, so it is between 0 minutes and 2 hours. Seems perfectly normal so far. You wouldn't expect 5 starts any day, but on some, yes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .