Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cron jobs failover on hacmp

Status
Not open for further replies.

tech123786

Technical User
Nov 13, 2006
31
US
Hello,
Is there anyway to make the all the cronjobs reltaed to a specific users (ex: database)to failover with the resources from a primary node to a secondary node (in all types of failovers) and vice versa? Any suggestions..


Thanks
 
Our cronjobs run on both sides of the cluster but have, as the first part of the script, a test for the existance of the relevant filesystems.
i.e our filesystems are
/thishost/usr/<mount point> and
/thathost/usr/<mount point>.

So a cronjob can start
Code:
[[ -d /thathost/usr/thatmount/subdir ]] && RunOtherHostJob

Ceci n'est pas une signature
Columb Healy
 
Columb,
Thanks for the response.
Running cronjobs on both nodes is not an option . I was looking for a way to failover a primary nodes cronjobs on secondary and vice versa so there would be no need for users to update cronjobs on bothsides each time if they want to change something.

Could you please explain be clearly how this can be achieved?


Thanks
 
1. Add the following to your resource group's crontab:
Code:
# Copy this crontab to /resource-filesystem every day
0 0 * * * /usr/bin/crontab -l /resource-filesystem/${CRONUSER}.crontab

2. In the application stop script:
Code:
crontab -r $CRONUSER

3. In the application start script:
Code:
echo "Implementing ${CRONUSER} cron..."
cp /resource-filesystem/${CRONUSER}.crontab /var/spool/cron/crontabs/${CRONUSER}
chmod 644 /var/spool/cron/crontabs/${CRONUSER}
chown root:cron /var/spool/cron/crontabs/${CRONUSER}
su - ${CRONUSER} -c "crontab -v"
 
Spamly,
Thanks for the info, could you explain me little more about 1. Add the following to your resource group's crontab:

CODE
# Copy this crontab to /resource-filesystem every day
0 0 * * * /usr/bin/crontab -l /resource-filesystem/${CRONUSER}.crontab
What do you mean by resource group crontab?

Thanks
 
Sorry about that. The point of that snippet is to regularly copy your users crontab to a standard location. This should be part of the users crontab. I do this daily so that if I do failover, it will have a crontab that is no more than 24 hours old.
 
I don't know how effective this solution would be but i thought of trying it on one of my test clusters (not done it yet) and see how it works!

you can copy the crontab file over to the second node!

scp /var/spool/cron/crontabs/root secondNodeName:/var/spool/cron/crontabs/root

you can add this line to the cluster events or even (but not recommended) in the start-stop application scripts.

Regards,
Khalid
 
Thanks Spamly, I will try this out. And one more thing is if the node crashes then it will not stop the apps server , in that case it's better to add crontab -r $CRONUSER in /etc/rc.d as well as app stop script.



Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top