1834434 Members
2459 Online
110067 Solutions
New Discussion

Cron in MCSG

 
SOLVED
Go to solution
Rashid Hamid
Regular Advisor

Cron in MCSG

I have 2 nodes (active-stanby)MCSG running 4 with packages. During fail over from first node to second node, I need to stop cron in the first node and run the crons in second node.
What is the best solution to cater this cron?

I'm Parit Madirono/Parit Betak Boyz
2 REPLIES 2
Ralph Grothe
Honored Contributor
Solution

Re: Cron in MCSG

There seem several solutions likely.
You could pre-create two different versions of crontabs of which you move the one in place to /var/spool/crontabs/ which is applicable for either the case that the package is running on this node or isn't.
This can be executed from within your package's control script.
However, if your SG specific cronjobs are just a few you could also put some logic in the cronjob or their wrapper script like e.g.

cmviewcl -p $PACKAGE|awk '$1==pkg&&$NF==node{exit 9}' pkg=$PACKAGE node=$(uname -n)
(( $? == 9 )) && run_cronjob
Madness, thy name is system administration
Stephen Doud
Honored Contributor

Re: Cron in MCSG

The following simple yet elegant solution has been suggested in the
http://ITRC.hp.com Serviceguard forum by several customers.

--------------------------------------------------------------------------------
Run package-related cron jobs on every node in the cluster but use a wrapper
script to test whether the package is running on the current node before
initiating the cron tasks.

For example, each node would have the same cronjob entries:
00 01 * * * /usr/local/bin/hacron packageA /etc/cmcluster/pkgAcrontasks
00 * * * * /usr/local/bin/hacron packageB /etc/cmcluster/pkgBcrontasks

hacron (Highly Available cron) might look something like: -

#!/usr/bin/sh
pkghost=`cmviewcl | grep | awk {'print $5'}`
thishost=`uname -n`
if [ "$pkghost" = "$thishost" ]; then
shift
$*
fi


The wrapper script is passed the name of the package it will check for and
the package-specific task list path. At the cron'd time, the scripted test
verifies the package is running on the node. If it is, the task script is
executed.