安排任务在每个月底运行。(Windows Server 2003 - 计划任务)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3620009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 15:09:49  来源:igfitidea点击:

Scheduling a task to run at the end of every month. (Windows Server 2003 - Scheduled Tasks)

windowswindows-server-2003scheduled-tasks

提问by S.Jones

I need to schedule a task to run on the last night of each month, on a Windows 2003 Server.

我需要安排一个任务在每个月的最后一个晚上在 Windows 2003 服务器上运行。

I see that you can schedule it to run on the "first or last Mon-Fri", or even on the nth day of each month - but, not how to get it to run on the last day (regardless of day of the week or number).

我看到您可以安排它在“第一个或最后一个周一至周五”,甚至每个月的第 n 天运行 - 但是,不是如何让它在最后一天运行(无论一周中的哪一天)或数字)。

Thanks in advance.

提前致谢。

Note: I did check "How do you schedule tasks in Windows?", etc...

注意:我确实检查了“您如何在 Windows 中安排任务?”等...

回答by Mike Schenk

Looks like you have to set up multiple schedules for your task. One schedule for the months with 31 days, another for those with 30, and one more for February. See this: http://support.microsoft.com/kb/936627

看起来您必须为您的任务设置多个时间表。一个是针对有 31 天的月份,另一个针对有 30 天的月份,还有一个针对 2 月。请参阅:http: //support.microsoft.com/kb/936627

回答by Scott

I do it a little differently - I run one task every day but since the task is in vbscript - I do this:

我的做法有点不同——我每天运行一项任务,但由于该任务在 vbscript 中——我这样做:

DIM datecur, datefut


datecur = DATEPART("m",NOW())
datefut = DATEPART("m",NOW()+1)

If (datecur <> datefut) then
'insert code you want to run here
end if

Simple and it works - hope this helps someone

简单且有效 - 希望这对某人有所帮助