Operating System - HP-UX
1833758 Members
3010 Online
110063 Solutions
New Discussion

Re: application crons in 2 node cluster

 
Dianne Dearring
Occasional Contributor

application crons in 2 node cluster

Does anyone have a recommendation for managing application crons? Our app is running on only one server or the other, so we don't want cron running on the backup server. Thanks!
No one is useless in this world who lightens the burdens of it for another. -Charles Dickens
8 REPLIES 8
Maureen Gunkel
Trusted Contributor

Re: application crons in 2 node cluster

Dianne,
I have had to create a solution to this, and I have all the pieces except the 'trigger' to invoke my script. Basically, I have written a script that does a crontab -l > file, rcp's that file to the backup server, starts cron on the backup server (using remsh), and then disables cron on the 'downed' server. Then the reverse happens once the 'downed' server comes back up.
Oh, and to disable cron, I am just submitting an empty crontab file.
Hope this helps,
Mo
No matter where you go, there you are.
BradF
Frequent Advisor

Re: application crons in 2 node cluster

I was thinking about setting up a cron on our cluster but we decided to do it a different way.

My thought was to setup the cron on both the servers. Inside the script run by cron I would check if the package was running on the server via cmviewcl or some other way. If the package was not running it would exit out of the script otherwise it would continue and run the script.
Lothar Krueler
Regular Advisor

Re: application crons in 2 node cluster

Hi Dianne,
I think Brad`s suggestion is a good way. In our 2 node cluster i had the same problem. On every node several cron-jobs are to run. Since 1 year i use the attached script rip (run in package) and roh (run on host). The 2 crontabs are identical, I only edit the crontab file at the one node and do an rcp (by cron) once a day to the other node.
The script is very easy, so i think i do not have to translate the comments.

sorry, i only can attach one file, so i'll cat rip roh >>rip+roh
Regards , Lothar
Wissen macht zaghaft, Dummheit kann alles!
Stephen Doud
Honored Contributor

Re: application crons in 2 node cluster

Hi Dianne,

I got curious about this. Though it' not a ServiceGuard failing, others have asked about it.

Maureen mentioned a 'trigger' to determine when to switch cron jobs. I can't think of a good trigger.

Brad's suggestion to use cron appealed to me.

Here is a simple script cron can call that may help:

#!/sbin/sh
#
# The purpose of this script is to demonstrate one way that
# the system can be programmed to determine if the local host
# should be cron'd to run special instructions based on whether
# a ServiceGuard package is running on the local host.
#

P_NAME=aclk <-- (put your package name here)
PKG_LOC=`cmviewcl -p $P_NAME | grep $P_NAME | awk '{print $5}'`
HOST=`uname -n`
if [[ $PKG_LOC != $HOST ]]
then /usr/bin/crontab /root/cron/std_crontab
else /usr/bin/crontab /root/cron/pkg_crontab
fi

# pkg_crontab contains everything in std_crontab plus extra commands
Stephen Doud
Honored Contributor

Re: application crons in 2 node cluster

This one hooked me :)
I created UXSGKBQA00000066 describing one way to implement matching cron jobs to package location.

Hope it helps.

-Stephen
BradF
Frequent Advisor

Re: application crons in 2 node cluster

Changing the crontab file looks like it would work fine. But my thought was to change the script that is called by cron. If the PKG is not running on the server the script would exit gracefully.

# Script to run on Server if PKG is running
PKG=
PKG_LOC=`cmviewcl -p $PKG | grep $PKG | awk '{print $5}'`
HOST=`uname -n`

if [[ $PKG_LOC != $HOST ]]; then
exit
fi

# run cmds on server.

This can be implemented without changing Service Guard, testing failover and creating two crontab files for each server.
Stephen Doud
Honored Contributor

Re: application crons in 2 node cluster

Dianne,

If you are handing out points - give them to Brad for his elegant approach!

Brad, if you don't mind, I'll replace my document with your idea!

-Stephen
Peggy Fong
Respected Contributor

Re: application crons in 2 node cluster

Another way we handled cron was to put the master cron for the application in their file system (provided it moves with the package). The trigger is the package halt and start. On the halt a crontab -r for that application id is executed. On the startup of "crontab filename appl_id" is run where the filename is the master cron file for the application in their agreed upon location.
Sorry I don't have the script for this - took an early retirement and didn't have time to get all my scripts...

This only works with a unique application-id that moves from node to node.

Peggy