Microsoft KB Archive/936627

= A task does not run in certain months when you use the Schtasks command-line tool on a Windows Server 2003-based computer =

Article ID: 936627

Article Last Modified on 10/11/2007

-

APPLIES TO


 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Web Edition
 * Microsoft Windows Server 2003, Datacenter Edition for Itanium-Based Systems
 * Microsoft Windows Server 2003, Datacenter x64 Edition
 * Microsoft Windows Server 2003, Enterprise Edition for Itanium-based Systems
 * Microsoft Windows Server 2003, Enterprise x64 Edition
 * Microsoft Windows Server 2003, Standard x64 Edition

-



SYMPTOMS
When you use the Schtasks command-line tool on a Microsoft Windows Server 2003-based computer to schedule a monthly task, the task does not run in certain months.

You experience this problem if the following conditions are true:
 * You use the lastday option in the schtasks command to schedule the task to run on the last day of the specified months.
 * The months that you specify in the schtasks command have different numbers of days.

Note The Schtasks command-line tool supports the lastday option for monthly schedules. This option requires a list of the months in which to run the task.



CAUSE
This problem occurs because of how the Schtasks command-line tool stores the dates to run the scheduled task when you use the lastday option. If the months that you specify in the schtasks command have different numbers of days, the task is skipped in the months that have fewer days.

Consider the following example. You type the following command to schedule the c:\myapp.exe program to run on the last day of January, on the last day of February, and on the last day of March:

schtasks /create /tn &quot;My App&quot; /tr c:\myapp.exe /sc monthly /mo lastday /m JAN,FEB,MAR /st 18:00

The Schtasks command-line tool uses the following logic to schedule the task:

Run on day  in months ,  ,

In this example, the Schtasks command-line tool uses the following settings to schedule the task that you specified:

Run on day 31 in months January, February, March

However, because February 31 is a date that is not valid, the task does not run in February.



WORKAROUND
To work around this problem, use the Schtasks command-line tool to schedule separate tasks for the months that have different numbers of days.

For example, to schedule a task to run on the last day of every month at 23:00, run all the following commands:
 * schtasks /create /tn &quot;My App (Feb)&quot; /tr c:\myapp.exe /sc monthly /mo lastday /m FEB /st 23:00
 * schtasks /create /tn &quot;My App (30)&quot; /tr c:\apps\myapp.exe /sc monthly /mo lastday /m APR,JUN,SEP,NOV /st 23:00
 * schtasks /create /tn &quot;My App (31)&quot; /tr c:\apps\myapp.exe /sc monthly /mo lastday /m JAN,MAR,MAY,JUL,AUG,OCT,DEC /st 23:00

Keywords: kbtshoot kbprb KB936627

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.