Setting up a scheduled task on a windows cluster

Posted on 2006-06-01
Last Modified: 2013-11-15
How can I setup a scheduled task on windows 2003  in a active/passive cluster. Say if the server A  which is the active server fails then the server B should be able to run the scheduled task.

Question by:life_j
    LVL 29

    Expert Comment

    I'm not sure if this is the nest way but I have a vbs script that pings hosts every 20 minutes from a clustered monitoring system. This is how I set it up.

    From the active node - Create the scheduled task as normal and make sure that the file you are excuting is stored on the shared clustered resource.

    Fail over the system so the other node is now active and re-configure the task pointing to the same copy of the file you want to run on the shared storage.

    Now since the active node places a lock on the shared storage disk only the active node will be able to run the scheduled task successfully therefore as long as one node is up and has access to the shared disk then that node will be able to run the task.

    As I said I'm not sure if there is a better way but this works for me in this instance. If anyone else has a nicer way I'd love to know also.
    LVL 7

    Author Comment

    Can you please paste the script that your are using. I will see If I can modify the script so that I can use it.
    LVL 29

    Expert Comment

    Do you want a copy of the ping vbscript?
    LVL 7

    Author Comment

    LVL 29

    Expert Comment

    I'm out of the office at the moment. I'll be able to drop a copy in at the end of the week.
    LVL 7

    Author Comment

    Thanks mass2612
    LVL 29

    Accepted Solution

    Here you go.

    I run this using a scheduled task that run a cmd file every 20 minutes.

    Some of the lines may have wrapped here due to length. The input file is called servers.txt and contains the list of server hostnames or IP addresses you wish to ping.You need to updated the line and the to, from lines.

    CMD file
    cscript.exe pingservers.vbs


    Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
    Set objShell = WScript.CreateObject("WScript.Shell")
    'Here you can set how many pings you want to send, and how long to wait for the response
    pingNumber = 4
    'note this is in milliseconds
    timeOut = 10000
    InputFile = "servers.txt"
    Set objFile = objFSO.OpenTextFile(InputFile,1,FALSE)
    Do Until objFile.AtEndOfStream
          strServer = objFile.ReadLine
          'Give the ability to comment out servers
          If Left(strServer,1) = "'" Then
                strSrvNameLen = Len(strServer)
                WScript.Echo "Skipping server " & Right(strServer,(strSrvNameLen - 1))
          WScript.Echo "Pinging " & strServer & "..."
          Set objPing = objShell.Exec ("ping " & strServer & " -n " & pingNumber &" -w " & timeOut)
          strPingOut = objPing.StdOut.ReadAll
          If (Split(strPingOut," ")(0)) = "Unknown" Then
                WScript.Echo strPingOut
                arrPingWholeReturn = Split(strPingOut,"Received")
                arrPingData = arrPingWholeReturn(1)
                arrPingResult = Split(arrPingData," ")
                If arrPingResult(2) = "0," Then
                      'Box or network is dead - better tell someone
                      WScript.Echo strServer & " - Ping timed out. Machine may be down."
                      'Grab a reference to the email object
                      Set objMessage = CreateObject("CDO.Message")
                      'Send an email with the results... self explanatory!
                      objMessage.Subject = strServer & " - Ping timed out"
                      objMessage.Sender = ""
                      objMessage.From = ""
                      objMessage.To = ""
                      objMessage.TextBody = strPingOut
                      objMessage.Configuration.Fields.Item ("") = 2
                      'SMTP Server
                      objMessage.Configuration.Fields.Item ("") = ""
                      'SMTP Port
                      objMessage.Configuration.Fields.Item ("") = 25
                      'Don't really need to do anything... maybe write a log file?
                      WScript.Echo strServer & " ping response OK"
                End If
                End If
          End If
    'Cleanup vars
    Set objShell = Nothing
    Set objMessage = Nothing

    *** End of script ***


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    Replication has always been one of those technologies that people run scared from. The main reason is usually cost. When you think of replication, your mind drifts to solutions that replicate from one disk frame to another using block level technolo…
    How to fix error ""Failed to validate the vCentre certificate. Either install or verify the certificate by using the vSphere Data Protection Configuration utility" when you are trying to connect to VDP instance from Vcenter.
    This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
    This tutorial will show how to inventory, catalog, and restore media from legacy versions of Backup Exec into both 2012 and 2014 versions of the software. Select Storage from the tabs along the ribbon bar as the top: Ensure the proper storage devi…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now