The command line interface to the Task Scheduler is named At.exe.
- 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.
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 saving 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.
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.
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.
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).
- 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.
- 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.
- 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.
- In Control Panel, open Scheduled Tasks.
- Right-click the task that must have a special schedule, and then click Properties.
- 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.
- Also on the Schedule tab, click to select the Show multiple schedules check box.
- 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
- Click OK.
- 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
- On the Settings tab, click to clear the Delete the task if it is not scheduled to run again check box.
- Click OK or Apply.
- 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:
- Log on to the computer as a user who has rights to change the system time, such as an administrator.
- In Control Panel, double-click Date and Time.
- On the Time Zone tab, click to clear the Automatically adjust clock for daylight saving changes check box. Click OK or Apply.
ID do Artigo: 325413 - Última Revisão: 31 de jan de 2007 - Revisão: 1