INFO: Task Scheduler Behavior at Daylight Savings Time Transitions and Other Events (325413)



The information in this article applies to:

  • Microsoft Windows XP Professional
  • Microsoft Windows 2000
  • Microsoft Windows NT 4.0

This article was previously published under Q325413

SUMMARY

The behavior of the Microsoft Task Scheduler is not specified for tasks that are scheduled to run during the transition hours to and from Daylight Savings Time. Other events can also affect the actual time that a scheduled task runs. This article describes the observed behavior of recent versions of Task Scheduler.

back to the top

MORE INFORMATION

A built-in Task Scheduler component is included with Windows 2000 and later operating system (OS) versions. For Microsoft Windows NT 4.0, when you install Microsoft Internet Explorer version 4 or later, the install adds Task Scheduler to the system. The Task Scheduler is made up of the MSTask.exe service file and a user interface (UI) component in MSTask.dll that you can use through Windows Explorer or through Control Panel. In Internet Explorer 4 versions, these files are named Mstnt.exe and Mstnt.dll, respectively. Starting with Windows XP, the Task Scheduler service is Schedsvc.dll, which is hosted by SvcHost.exe in the Netsvcs group.

The command line interface to the Task Scheduler is named At.exe. The Microsoft Task Scheduler service implements the ITask, IScheduledWorkItem, and related interfaces, and the UI uses these interfaces to add, to edit, and to enumerate scheduled tasks. The interfaces permit a variety of triggers that you can combine in many ways to cause a task to start when the combined conditions are met. These triggers can include the following:
  • when a specified user logs in.
  • when the system is idle for a specified time.
  • when a specified date and time occurs.
  • when a specified time interval passes.
Typically, these conditions correspond directly to selections that appear in the Task Scheduler UI.

Methods in these interfaces accept schedule time data in SYSTEMTIME format. The SYSTEMTIME format is not set for any local time zone. This format can store the current system time, based on coordinated universal time (UTC), but any value that it stores is also valid in any time zone. This value must be interpreted in context. The Task Scheduler UI and the command line assume that times and dates are in local time units.

The system time can change irregularly for several reasons. When the system starts, it reads the time from the computer's real-time clock, which it interprets as a local time and then converts to UTC-time. After startup, the system updates its own copy of the clock on regular interrupts.

At any moment before or after system startup, you can change the system time. You can also synchronize the time to an external time source, and the system can adjust the time on each clock update. If you specify automatic daylight savings time (DST) adjustment for the system, there will be two time transitions during a calendar year when the time is advanced or receded by one hour.

There is nothing in the Task Scheduler UI to direct how a task is treated because of changes in the system time. There is nothing in the programming interfaces to manage such scenarios, either. The following describes what may occur if a task's start time or end time occurs in a DST transition hour.

back to the top

Daylight Savings Time (DST) Transitions

This article uses the terms Spring Forward (SF) and Fall Back (FB) to designate the two Daylight Savings Time transition scenarios.

Spring Forward occurs when DST goes into effect: the system time is adjusted forward by one hour, for example at 2:00 a.m. Sunday morning local time. Therefore, times between 2:00:00 and 2:59:59 do not appear in the system on that date in that time zone.

The reverse occurs during Fall Back: the system time is adjusted back by one hour, for example at 2:00 a.m. Sunday morning local time. For that time zone, the minutes between 1:00:00 and 1:59:59 repeat; they occur two times in the system.

back to the top

Spring Forward
There are several possible ways that a scheduler program might behave for tasks that are scheduled in the time void that is caused by the SF transition:
  • Method 1
    Because those minutes do not appear for that day in that time zone, the scheduler may ignore any tasks that are scheduled to occur during those minutes. This behavior may be appropriate for some applications; the scheduler does not prevent those times from being placed in the schedule.
  • Method 2
    Start those tasks at the actual time that they would have been started, had DST not occurred. For example, a task that is scheduled to occur at 2:05 that morning would actually run at 3:05 DST. This approach may be useful for tasks that must be staggered and sequenced. However, this approach may cause one task to run after another task that is dependent on the first task. For example, if one task is scheduled at 2:30, and a followup task is scheduled at 3:15, the 3:15 task may run first, followed by the 2:30 task, which would now run at 3:30.
  • Method 3
    Compress time, and then run any missed tasks in the order that they were scheduled to run at some time after the transition. This behavior keeps tasks in order. However, if several tasks are scheduled during the SF time void, they appear to start almost simultaneously. Any interdependencies that require specific timing and sequence might cause failures of steps in the task. This appears to be the method that the latest Microsoft scheduler uses.
back to the top

Fall Back
The following are several ways that a scheduler program might behave for tasks that are scheduled during FB, when time repeats:
  • Method 1
    Because the time repeats, do the task again each moment that the scheduled time occurs. This does not appear to be a common requirement; however, this behavior might be appropriate for some applications.
  • Method 2
    Start those tasks at the actual time that they would have started had DST not occurred. For example, a task that is scheduled for 2:05 that morning runs at the 1:05 standard time, which is the second 1:05 wall-clock time.
  • Method 3
    Start the tasks at the scheduled wall-clock hour. This behavior delays any tasks that are scheduled to start at 2:00 DST on that date for one hour, but all tasks beyond that time occur in the sequence and at the actual time interval that you want. The latest Microsoft scheduler appears to use this method. However, tasks that are scheduled to occur exactly at the transition moment may run at that moment. For example, a task that is scheduled to occur at 2:00 a.m. might run at 1:00 a.m. standard time (as in method 2).
back to the top

Events That Affect Task Scheduling

As currently implemented, the Task Scheduler periodically builds a wait list of upcoming tasks. This list contains the tasks that must run through the next midnight hour. Several events cause the scheduler to reevaluate and rebuild this list. Those events include the following:
  • Startup of the service.
  • A system time change, unless it is by a few minutes.
  • When the computer wakes up from a sleep state.
  • A change in the scheduled tasks folder. This includes when a new task is created, or when the properties of an existing task are updated (insignificant changes, such as to change the comment or the credentials, does not trigger a rebuild).
  • When the list time expires, typically at midnight.
back to the top

Skipped Tasks

The Task Scheduler can skip tasks, for example, because of a long system downtime or a calendar change. Tasks that are missed because of a DST transition typically are not skipped. However, they are brought up-to-date when the scheduler runs to start a task, or when tasks are rescheduled (such as when an event causes the scheduler to rebuild the wait list). These tasks appear to run at one of the following times:
  • The transition instant. For example, if a task is scheduled to run at 2:00 a.m., this task and any later tasks that are scheduled in the 2:00 hour run immediately at 3:00 a.m. DST.
  • Immediately before the scheduler runs the first scheduled task after the transition hour. For example, if a task is scheduled to run at 2:15 a.m., and another task is scheduled to run at 3:10 a.m., at 3:10 a.m. the skipped task is started, and then the task that is scheduled for 3:10 a.m. runs.
The scheduler should run tasks in the order in which they are scheduled. If more than one task is scheduled for the same time, they run in the order that they appear in the unsorted Scheduled Tasks folder. A new task that is scheduled for the current system minute may run almost immediately if it is early in that minute. If the task does not run immediately, the scheduler may skip the task or schedule the task to run at its next repeat interval. back to the top

Plan for Daylight Savings Time (DST) Transitions

To work with the existing behavior of the Task Scheduler, the best practice is to have an advance plan to create special cases for those two dates each year. The following are some suggestions for such a plan:
  • Schedule tasks to run in time slots that are not affected by DST transitions. For example, if the local time changes at 2:00 a.m., avoid scheduling tasks between the hours of 1:00 and 2:59:59 a.m.
  • Use the advanced scheduling capabilities of Task Scheduler to create special cases for those days. The following steps describe one way to do this.

    NOTE: The settings in this example apply only to regions where the DST transitions occur on the first Sunday in April and the last Sunday in October. Use your local settings in these steps to create special schedules for your area.
    1. In Control Panel, open Scheduled Tasks.
    2. Right-click the task that must have a special schedule, and then click Properties.
    3. On the Schedule tab, click Advanced. Click to select the End Date check box, and then type the date before the Spring Forward DST transition is scheduled to occur. Click OK.
    4. Also on the Schedule tab, click to select the Show multiple schedules check box.
    5. Click New. Set the following properties:
      • Schedule Task - set to Monthly
      • Start Time - set to the time that you want
      • Schedule Task The - set to first Sunday
      • Select Months - click to clear the check boxes for all of the months except April

    6. Click OK.
    7. Repeat steps 5 and 6 to create a new Fall Back schedule that has the following properties:
      • Schedule Tasks The - set to last Sunday
      • Select months - click to clear the check boxes for all of the months except October

    8. On the Settings tab, click to clear the Delete the task if it is not scheduled to run again check box.
    9. Click OK or Apply.
    10. After the DST transition has passed, change the properties on the Schedule tab again (clear the End Date setting for the primary schedule).
  • Turn off automatic DST adjustments for this computer, so that all of the tasks continue to run on a standard time schedule:
    1. Log on to the computer as a user who has rights to change the system time, such as an administrator.
    2. In Control Panel, double-click Date and Time.
    3. On the Time Zone tab, click to clear the Automatically adjust clock for daylight saving changes check box. Click OK or Apply.
    At a convenient time, during the day that DST changes and when no tasks are scheduled to run, you can manually change the system time (in Control Panel, click the Date & Time tab to locate this setting).
back to the top

Modification Type:MajorLast Reviewed:11/5/2002
Keywords:kbinfo KB325413