代码之家  ›  专栏  ›  技术社区  ›  Andrew G. Johnson

希望在我的IIS服务器上设置某种cron等价物

  •  3
  • Andrew G. Johnson  · 技术社区  · 15 年前

    我在一个ASP文件中编写了数据库填充代码,只需要确保它每天都能运行。最好的方法是什么?我对这里的最佳实践不是很熟悉,如果我只是让预定的任务打开iexplorer,指向运行scraper的URL,或者有什么方法可以通过命令行完成它。最担心的是,我试图将如何在PHP-on-LAMP中将其转换为ASP/WISA,而不是将其视为自己的问题。

    4 回复  |  直到 15 年前
        1
  •  2
  •   Joel Etherton    15 年前

    我建议不要使用脚本调用来实现这一点。这最好使用从任务计划程序调用的.Net控制台应用程序来完成。

        2
  •  2
  •   alumb    15 年前

    windows计算机上cron的等价物是“调度任务”。Windows XP的操作方法如下: http://support.microsoft.com/kb/308569 . 大多数版本的windows都可以遵循类似的步骤。

    如果将数据筛选代码放在asp文件中,则可以使用以下VBS脚本对该文件发出http请求:

    Const WinHttpVersion = "5.1"
    Dim objWinHttp, strURL
    
    ' Request URL from 1st Command Line Argument.  This is
    ' a nice option so you can use the same file to
    ' schedule any number of differnet scripts.
    strURL = WScript.Arguments(0)
    
    ' For more WinHTTP v5.0 info, go to Registry Editor to find out 
    ' the version of WinHttpRequest object.
    Set objWinHttp = CreateObject("WinHttp.WinHttpRequest." & WinHttpVersion)
    
    If IsObject(objWinHttp) Then
        objWinHttp.Open "GET", strURL
        objWinHttp.Send
        If objWinHttp.Status <> 200 Then
            Err.Raise 1, "HttpRequester", objWinHttp.ResponseText
        End If
        Set objWinHttp = Nothing
    End If
    
    If Err.Number <> 0 Then
        ' Something has gone wrong... do something about it...
    End If
    

    这样做的原因如下:

    HttpRequester.vbs http://localhost/MyApp/loadData.asp
    
        3
  •  1
  •   Paddy    15 年前

    你可能想创建一个在后台运行的windows服务——仅仅用一个ASP页面很难做到这一点。

        4
  •  0
  •   D'Arcy Rittich    15 年前

    wget curl

    无需编写脚本,只需将可执行路径作为要运行的进程,并将URL放在parameters字段中(再加上一些其他开关,具体取决于使用的程序)。