Schedule Task

P

Pegasus \(MVP\)

TBoon said:
The following sample is taken from
http://technet2.microsoft.com/Windo...9d11-46c2-a8ef-87b297c68d171033.mspx?mfr=true

schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday
/m *

It create the taks to run on Day 31 of every month.

But if a month has only 30 days, the schedule task does not get executed.
Eg. Apr, Jun has 30 days. Not forgetting Feb 28.

Any workaround for this?

Have you actually tested if this is a problem? I suspect that it is not and
that it is just a question of poor labelling in the Task Scheduler.
 
G

Guest

Yes, I have tested.
Apr, Jun, Sep, Nov and Feb does not have Day 31.
Therefore, the Task was not executed by the OS.
 
G

Guest

Yes, I have tested.
Apr, Jun, Sep, Nov and Feb does not have Day 31.
Therefore, the Task was not executed by the OS.

Dave Patrick said:
Have you confirmed this? That's not the way I read it.

http://www.microsoft.com/resources/.../xp/all/proddocs/en-us/schtasks.mspx?mfr=true

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

TBoon said:
The following sample is taken from
http://technet2.microsoft.com/Windo...9d11-46c2-a8ef-87b297c68d171033.mspx?mfr=true

schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo
lastday
/m *

It create the taks to run on Day 31 of every month.

But if a month has only 30 days, the schedule task does not get executed.
Eg. Apr, Jun has 30 days. Not forgetting Feb 28.

Any workaround for this?
 
P

Pegasus \(MVP\)

Yes, we all know that there is no Feb 31. However, a proper
test requires you to set the machine date/time to 11:30 pm on
27 February 2007, then to check if a task scheduled at five
minutes past midnight on the last day in February executes or not.
 
G

Guest

Yes, of course I tested by setting the OS datetime.
Not working.

Looks like the Scheduled Task is not clever enough to detect Months without
Day 31 and Day 30.
 
P

Pegasus \(MVP\)

This seems to be a bug in the Task Scheduler. Not very
impressive . . .

You can work around the problem by scheduling the following
batch file to run each day:

@echo off
if DateCalc(0,month) NEQ DateCalc(1,month) c:\YourTask.exe

where DateCalc is some date calculator that returns the month
name for any given offset. You can probably find lots of them
on the net. It is also possible to do it with a batch file, using Zeller's
Theorem. However, the code is not trivial and takes about a dozen
command lines.
 
T

TBoon

I created 4 schedules for a Task that need to run last Day of the month.
1. Day 30 for Apr, Jun, etc
2. Day 31 for Jan, Mar, etc
3. Day 28 for Feb
4. Day 29 for Feb leap year
 
B

Bob I

Perhaps the reason is, and I quote from the article:
---------------
Remarks

This help file describes the version of Schtasks.exe included in the
Windows Server™ 2003 family. For information about the version of
Schtasks.exe in Windows XP Professional, see the Schtasks topic in
Windows XP Professional Help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top