4

我正在寻找相当于 Windows 的 Cron 系统。这个想法是能够安排一个触发器并监控它是否成功运行。

系统需要做的事情如下:

  • 它应该能够触发 Win32 COM 对象和/或可执行文件。
  • 它应该能够触发 .NET COM 对象和/或 .NET 可执行文件。
  • 它应该能够触发以任何语言编写的脚本,无论是基于本机框架(Python、Perl、Ruby)还是基于 DLR(IronPython、Ruby.NET 等)
  • 脚本应介于需要几秒钟的简单脚本和可能需要半小时的相当繁重的脚本之间。

监控方面至关重要。所以基本上我正在寻找以下内容:

  • 如果脚本或可执行文件失败,则应发送电子邮件或其他通知机制。
  • 应该记录每个触发器,以便我们可以回顾一下代码何时失败。
  • 故障应该很容易通过某种调试输出或堆栈跟踪来跟踪。

是否有任何 Windows 开发人员创建了这样的系统?我知道在 UNIX 世界中有 Cron,但在 Windows 世界中呢?

4

8 回答 8

7

在命令提示符下键入“at”

> at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       Allows the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is assumed.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next Thursday).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.
于 2009-03-12T11:11:48.543 回答
6

您应该能够将计划任务用于上述所有操作。

于 2009-03-12T11:05:14.673 回答
3

我建议在 Vista/Server 2008 中查看修订后的 Task Scheduler 2.0。它比以前版本的 Windows 中的 1.0 强大得多,现在能够

  • 基于事件的触发器,例如每次导致应用程序事件代码 1053
  • 失败任务的触发器(对我来说最大的补充)
  • 更多内置操作,例如发送电子邮件而不是调用 blat.exe

查看您的清单,我相信您正在寻找的一切都已经存在。

于 2009-03-12T12:40:16.457 回答
1

您看过 Windows 调度程序吗?它似乎满足了您的大部分(如果不是全部)要求,并且已经包含在操作系统中。您可以在MSDN中找到它的文档

于 2009-03-12T11:06:03.550 回答
1

如果您想要一个脚本来“触发 Win32 COM 对象和/或可执行文件”、“触发 .NET COM 对象和/或 .NET 可执行文件”、记录失败并通过电子邮件通知失败,这听起来像是PowerShell的工作。

PowerShell 没有为您完成日志记录和发送电子邮件,而是一种编程语言,您可以在其中相当轻松地记录或发送电子邮件(或其他)。

我已经安排 PowerShell 脚本使用“at”/“Task Scheduler”服务成功运行。这是一个很好的组合。

于 2009-03-12T12:02:32.430 回答
1

看看nnCron。我正在使用精简版。它有一个 unix crontab 语法。有一个日志文件,但至于更高级的监控方面,由您的脚本/应用程序提供详细信息,例如。返回结果代码(将被记录)。

nnCron Lite 是我发现的最好的 windows cron 克隆(免费,无 perl 要求,crontab,错过的任务,作为隐藏窗口运行,设置环境变量 - 对 postgres “dump all”工具等有用)。

于 2009-03-12T16:46:41.847 回答
0

看看这里:Cron for Windows。还有一些为(免费)DOS 移植的类似 Cron 的软件,应该可以在 Windows 上运行,但我不记得名字了。

于 2009-03-12T11:06:16.077 回答
0

您是否尝试过将 JIT-Scheduler 与 PowerShell 结合使用?

http://shareme.com/download/jit-scheduler.html

于 2009-03-12T12:32:36.693 回答