Setting up a scheduled task on a windows cluster

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.

Who is Participating?
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 ***

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.
life_jAuthor Commented:
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.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Do you want a copy of the ping vbscript?
life_jAuthor Commented:
I'm out of the office at the moment. I'll be able to drop a copy in at the end of the week.
life_jAuthor Commented:
Thanks mass2612
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.