cancel
Showing results for 
Search instead for 
Did you mean: 

Best Method: Cron usage during failover

spores
Level 2
What is the best method for keeping the cron working on a second node during failover. I run numerous scripts all day long that are vital to my operation. I essentially need the crontab from node one to copy itself and run automatically on node two during failover.

Thanks!
4 REPLIES 4

Gene_Henriksen
Level 6
Accredited Certified
Rewrite the scripts with a wrapper that determines where the service group is online and makes the decision to run only if it the service group affected by this script is on the local system.

For example:

Only run script if OracleDG is online on local system. To figure out how to script this look at some code in the existing VCS bin directory, for example, fdsetup has this:

 my ($sta) = split('\n', `$HAGRP -value $CFG{RSG} State $fields[5]`);
       if (!($sta =~ /ONLINE/)) {
               _die("Please run this wizard on the node where $CFG{RSG} is onli
ne", 31, 1018, "$CFG{RSG}");

So in your case, it would if /OFFLINE/ that would cause the script to die, whereas ONLINE would be where you want it to run.

There are some really cooling scripting features in VCS commands, one of my favorites is "wait",  from fdsched:
 `$HAGRP -wait $fd State ONLINE -sys $attempt{$fd} -time 600`;

In this case we are waiting until the state of service group ($fd) is at a State of ONLINE, with a 600 second timeout.

Sorry this stupid web software converts a left paren into a smiley. It must be a Windows thing that I don't quite comprehend.

Message Edited by Gene Henriksen on 04-19-200708:52 AM

Message Edited by Gene Henriksen on 04-19-200708:53 AM

spores
Level 2
Thanks,
 
In that case, would something in the crontab like this work? If the service state is active (withing 30 seconds) this should execute the script???
 
15 * * * * `$HAGRP -wait $fd State ONLINE -sys $attempt{$fd} -time 30` /usr/local/mydir/myscript.sh
 
Sorry, I have never used VCS before. Thanks!

Gene_Henriksen
Level 6
Accredited Certified
I don't think that is what you want. Set up cron to run the job regardless. Setup the script to do the decision.

if `hagrp -State  ServiceGroup -sys SystemName` = "ONLINE" then
.....

I am technically on vacation and don't really have access to systems to test.

Gene_Henriksen
Level 6
Accredited Certified
symca !# more tester
if [ `hagrp -state ClusterService -sys symca`="OFFLINE" ]
then
echo "Offline, do not run script"
else
echo "Online, run script"
fi

The above example is what I am referring to. "ClusterService" is the service group name you supply. In the real script, you could test for ONLINE and if that is true run the cronjob, else exit silently or with a message to some log that the SG is offline here and will not run the script.