【问题标题】:Suggestions to run a program every specific period of time每个特定时间段运行程序的建议
【发布时间】:2010-11-16 14:09:48
【问题描述】:

有一个程序可以对存储在 SharePoint 中的文档进行爬网和索引。我需要每隔一段时间运行一次。我们的一些建议:

  • 将应用程序转移到 Windows 服务并安排它在每个周期运行。
  • 有一个程序会在每个时间段触发此应用程序。

您认为这两种方法中哪一种更有效。任何其他建议都非常受欢迎。谢谢。

【问题讨论】:

  • 不是重复的。这个问题是如何。这个问题是应该。是的,使用计划任务。计算机上运行的进程越少越好(google、adobe、apple 的一课,学习起来会很好)。此外,如果您的程序因任何原因崩溃(随机伽马射线翻转错误位),该进程将在下一个预定时间重新启动 - 而不是服务崩溃并且永远不会重新启动。
  • 我会每隔一段时间双击它。
  • @Luiscencio 你会告诉客户吗?
  • 他不会问,因为他不知道。他会认为它可以毫不费力地运行。

标签: .net scheduled-tasks


【解决方案1】:

使用 Windows 的 Task Scheduler。

【讨论】:

    【解决方案2】:

    如果您的程序足够简单,我会使用 Windows 的任务计划程序定期运行它(您的选项 #2)。无需为此编写 windows 服务。

    【讨论】:

    • 您可能指的是任务计划程序,而不是任务管理器 (taskmgr.exe)。
    • 谢谢!但是如何使用 Windows 任务管理器?这个选项在哪里?
    • @0xA3:是的。我的意思是任务计划程序! :-)
    【解决方案3】:

    您可以使用 DOS“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.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-29
      • 2018-12-26
      • 2011-09-06
      • 2023-02-15
      • 2015-01-13
      • 1970-01-01
      • 2019-08-12
      • 1970-01-01
      相关资源
      最近更新 更多