[DRBD-user] DRBH/HeartBeat and CROND

Alex Dean alex at crackpot.org
Thu Aug 23 05:09:31 CEST 2007

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


Rui Meireles wrote:
> Hi there.
> 
> I've sucessfully installed DRBD and HeartBeat in 2 servers using a
> Primary/Secondary configuration.
> 
> I'm using Heartbeat to start/stop some services, as NFS, HTTPD, MYSQLD ...
> I use several perl scripts that I created, and they are called at certain
> times of the day by the crontab of 2 users: "root" and "user1".
> 
> I'm tempted to use HeartBeat to start/stop service CROND, so only the
> PRIMARY runs the scripts. However, I'm afraid that stopping the CROND in the
> SECONDARY will stop some important services, such as rotating log files. Is
> this safe?
> 
> Is there any way for me to start/stop ONLY the "root crontab" and the "user1
> crontab" with heartbeat?
> 
> 
> Thanks a lot

I think you don't want to stop cron, because even when the box is 
secondary you need to do things like rotating log files, etc.

Some people I work with came up with this solution:

Create a directory structure like this : /etc/ha.d/crontab/<user>.

Each <user> directory has a file 'primary' and a file 'secondary'. 
These are crontab files to be run when the local machine is in either state.

They wrote a heartbeat resource script that looks at every directory in 
/etc/ha.d/crontab.
* If the node is becoming primary, it runs :
   crontab -u <user> /etc/ha.d/crontab/<user>/primary
* If the node is becoming secondary, it runs :
   crontab -u <user> /etc/ha.d/crontab/<user>/secondary

Adding a new user to this setup is just a matter of creating a new 
directory in /etc/ha.d/crontab.

We use svn to keep the 2 nodes in sync.  Whenever we need to change the 
cron jobs, edit the correct file, svn commit, and svn update on the 
other node.

alex



More information about the drbd-user mailing list