?
Solved

Setting up a scheduled task on a windows cluster

Posted on 2006-06-01
7
Medium Priority
?
1,257 Views
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.

Thanks
0
Comment
Question by:life_j
  • 4
  • 3
7 Comments
 
LVL 29

Expert Comment

by:mass2612
ID: 16814104
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.
0
 
LVL 7

Author Comment

by:life_j
ID: 16829245
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.
0
 
LVL 29

Expert Comment

by:mass2612
ID: 16829403
Do you want a copy of the ping vbscript?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Author Comment

by:life_j
ID: 16830080
yeah
0
 
LVL 29

Expert Comment

by:mass2612
ID: 16841197
I'm out of the office at the moment. I'll be able to drop a copy in at the end of the week.
0
 
LVL 7

Author Comment

by:life_j
ID: 16859117
Thanks mass2612
0
 
LVL 29

Accepted Solution

by:
mass2612 earned 375 total points
ID: 16866040
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 smtpserver.company.com line and the to, from support@company.com lines.

CMD file
cscript.exe pingservers.vbs

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))
      Else
      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
            Else
            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 = "support@company.com"
                  objMessage.From = "support@company.com"
                  objMessage.To = "support@company.com"
                  objMessage.TextBody = strPingOut
                  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                  'SMTP Server
                  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver.company.com"
                  'SMTP Port
                  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
                  objMessage.Configuration.Fields.Update
                  objMessage.Send
                  Else
                  'Don't really need to do anything... maybe write a log file?
                  WScript.Echo strServer & " ping response OK"
            End If
            End If
      End If
Loop
'Cleanup vars
Set objShell = Nothing
Set objMessage = Nothing

*** End of script ***

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you looking to recover an email message or a contact you just deleted mistakenly? Or you are searching for a contact that you erased from your MS Outlook ‘Contacts’ folder and now realized that it was important.
Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
Suggested Courses

807 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