Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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 "My App" /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 Number in months Month1, Month2, Month3
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.

↑ Back to the top


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 "My App (Feb)" /tr c:\myapp.exe /sc monthly /mo lastday /m FEB /st 23:00
  • schtasks /create /tn "My App (30)" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m APR,JUN,SEP,NOV /st 23:00
  • schtasks /create /tn "My App (31)" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m JAN,MAR,MAY,JUL,AUG,OCT,DEC /st 23:00

↑ Back to the top


Keywords: KB936627, kbprb, kbtshoot

↑ Back to the top

Article Info
Article ID : 936627
Revision : 3
Created on : 10/11/2007
Published on : 10/11/2007
Exists online : False
Views : 227