Scheduled Tasks on HA Pairs in Windows

Sometimes you might find yourself deciding that a Scheduled task is required for some report or file transfer on a production system. The production system, however, is part of a high availability (HA) pair. The particular method of dealing with HA in this particular ( hypothetical of course ) case works by moving an IP Address called a Virtual IP address between the servers of the HA Pair. Whichever server holds the VIP is the current node.

Your application needs to know if it is executing on the current node before starting.

Wrap your application in a very simple snippet of Comand Line script that:
  1. Looks for the VIP in ipconfig.
  2. If no errors found then jump to the section of your script that launches your application or another script to do the task.
  3. If an error is found then jump to the section of your script that notifies the log.

@echo off
REM #Testing FIND in IPCONFIG
SET VIPTHATWORKS="192.168.122.1"
SET VIPTHATFAILS="192.168.122.127"



ipconfig /all | find %VIPTHATWORKS%
if ERRORLEVEL = 1 goto VIP_NOT_FOUND

REM #We are here becuase the find returned a result.
REM #It is safe to execute the rest of the application.
echo "VIP Found. - Continuing with application..."

REM #Pause for user input.
pause
goto END_SCRIPT

:VIP_NOT_FOUND
REM #This part of the script is where you would handle any
REM #error logging or other admin related
echo "Could not find a VIP. - Exiting"

REM #Pause for user input.
pause
goto END_SCRIPT

:END_SCRIPT
echo "end of script reached."

Comments

Popular posts from this blog

Automatically mount NVME volumes in AWS EC2 on Windows with Cloudformation and Powershell Userdata

Extending the AD Schema on Samba4 - Part 2

Python + inotify = Pyinotify [ how to watch folders for file activity ]