cronhandler

Package: WA2L/edrc 1.5.57
Section: Maintenance Commands (1m)
Updated: 07 April 2008
Index Return to Main Contents

 

NAME

cronhandler - handle cron and at in a cluster environment

 

SYNOPSIS

edrc/bin/cronhandler [ -h ]

cronhandler -a { save | load | start } -s save_dir -u { userlist | homedir }

cronhandler -a stop -s save_dir

 

AVAILABILITY

WA2L/edrc

 

DESCRIPTION

With cronhandler it is possible to transfer crontab and at entries from one cluster node to another. This is important if users related to a MC/ServiceGuard package are allowed to use cron and at.

cronhandler takes care of the user`s crontab entries and transfers even defined at jobs to the other cluster node. Furthermore all cron and at control files ( cron.allow, cron.deny, at.allow, at.deny ) are maintained properly. Therefore it is ensured that a user related to a package can only define crontab and at entries if this user logs on to the node where the package is up and running (i.e. where the crontab entries and at jobs are loaded).

The basic concept of cronhandler is to save all crontab and at entries to a set of files located on a filesystem related to a MC/ServiceGuard package.

After the package switch the saved files are loaded and applied to the system where the package is starting. crontab entries are loaded like they were defined on the source node. If the execution of an at job falls into the short period of time between the package stop and a restart, the job will be rescheduled (current time + 60 seconds contingency time) on the target node. If there is a job planned on the target note at the same time a job from the source node likes to run, the job from the source node will be rescheduled one second after an already existing job.

Failover mechanism:

Preparation


 +
permanently write cron/at entries to the save_dir
( cronhandler started as daemon )

Failover situation

(1)
save cron/at entries to the save_dir
( cronhandler -a save ... ) .
(2)
stop cluster package on current node

 3
start cluster package on alternate node

 4
load cron/at entries from save_dir
( cronhandler -a load ... )

( ) = step will only happen if the cluster node can be shut down properly.

After a save or load the cron daemon is restarted to ensure that all possibly changed crontab definitions and at jobs are recognized again.

 

OPTIONS

-h
usage message.

-a
action:

save

save crontab entries and current at jobs of user(s) specified with the -u option to the directory specified with the -s option. After a save of the crontab entries and all current at jobs, the crontab and at jobs are removed from the system and the related user is no longer allowed to define crontab and at entries on the node. save is normally used to save crontab and at entries during a controlled cluster switch while halting the cluster package. After invoking -a save the cronhandler daemon is stopped.

load

load a previous saved crontab and at specification and allow the related user crontab and at definition where granted. After loading the saved jobs cronhandler enters into daemon mode and continues to run in the background. In daemon mode cronhandler writes all crontab entries and current at jobs of user(s) specified with the -u option in a regular interval to the directory specified with the -s option. The write interval can be specified in the config file edrc/etc/cronhandler.cfg with the setting WRITE_INTERVAL.

stop
stop the cronhandler daemon. Normally you don't have to stop the daemon by hand, it is stopped automatically after the save action has been invoked. The stop option is provided for ease of administration during maintenance tasks on the system when you don't want to have the cronhandler daemon running, but all cron and at jobs must continue to run.

start
start the cronhandler daemon. Normally you don't have to start the daemon by hand, it is started automatically after the load action has been invoked. The start option is provided for ease of administration during maintenance tasks on the system when you don't want to have the cronhandler daemon running, but all cron and at jobs must continue to run.

write
this action does no longer exist as command line option and is ignored if issued. It has no side effects (except for a logfile entry) if this option is still used.

-s save_dir
directory where to save all crontab and at data. See section FILES for the recommended permissions of this directory.

-u
userlist
a list of users separated by commas. The crontab and at entries of those users will be saved to the directory specified by the -s option.

homedir
if you have many users or if you like to react cronhandler dynamically on new/removed users you should use the definition of a $HOME directory. All subdirectories of the homedir will be considered as users. Therefore the username has to match with the $HOME (what is normally the case). See section EXAMPLES for a common setup.

 

SIGNALS

The following signals are handled by cronhandler. Do not use other signals as those listed below, as long as you do not really know what you are doing and what the consequences are. In general there is no need to invoke those signals by your own, this signals are used for inter process communication of cronhandler.

INT
kill the process with kill -SIGINT PID . Issuing this signal, the daemon will end.

TERM
kill the process without an argument ( kill PID ). Issuing this signal, the daemon will end.

 

EXIT STATUS

0
no error.

2
operating system is not supported. See osid(3) if you get this error.

4
usage listed.

7
the cronhandler has been started with the depreciated command line option -a write. This option is ignored from command line.

11
a temporary directory could not be claimed or created in /var/tmp. Check the system temporary directory /var/tmp if you get this error, it is an indicator of system intrusion.

 

FILES

etc/cronhandler.cfg
configuration file of cronhandler, see cronhandler(4) for more information. The configfile is reloaded in the interval defined in WRITE_INTERVAL, therefore all settings ( except LOCKDIR ) can be changed without stopping the cronhandler daemon.

var/log/cronhandler.log
logfile of cronhandler.

<save_dir>/
directory where to save the cron and at definitions. Due to security reasons the directory permissions should be root:sys, 0751 . You should not use this directory to save other data because it is maintained completely by cronhandler.

<save_dir>/cronhandler/action=save
flagfile if the last cronhandler action was save. This file contains the nodename where the action has been executed.

<save_dir>/cronhandler/action=write
flagfile if the last cronhandler action was write. This file contains the nodename where the action has been executed.

<save_dir>/cronhandler/<username>/cron/<username>
saved crontab.

<save_dir>/cronhandler/<username>/cron.allow=YES
flagfile if user was defined in cron.allow on source node.

<save_dir>/cronhandler/<username>/cron.allow=NO
flagfile if user was not defined in cron.allow on source node.

<save_dir>/cronhandler/<username>/at.allow=YES
flagfile if user was defined in at.allow on source node.

<save_dir>/cronhandler/<username>/at.allow=NO
flagfile if user was not defined in at.allow on source node.

<save_dir>/cronhandler/<username>/at/
directory to save currently defined at jobs for the user.

<homedir>/
user`s $HOME directory.

/usr/lib/cron/cron.allow /usr/lib/cron/cron.deny
List of users which are allowed/denied to create a crontab(1) on HP-UX and Solaris.

/etc/cron.allow /etc/cron.deny
List of users which are allowed/denied to create a crontab(1) on Linux.

/sbin/init.d/cron
Start/Stop script for cron(1m) on HP-UX.

/etc/init.d/crond
Start/Stop script for cron(8) on Linux and on Solaris.

/var/spool/cron/atjobs
at job spool dir accessed on Solaris only.

 

EXAMPLES

1) Common setup using MC/ServiceGuard

In this example the users sys_asys and ora_asys are related to a MC/ServiceGuard (see also http://www.hp.com ) package. Both users are allowed to create at jobs, but only the user ora_asys is allowed to have an own crontab. The filesystem /data_asys1 goes with the package (=moving disks) and is therefore used to carry the cron entries and at jobs from one to the other node.

1.1) /etc/passwd (on all nodes):

        :
        :
        ora_asys:adSKflweIRsdf:253:101::/data_asys1/home/ora_asys:/bin/ksh
        sys_asys:Wm9MyTyKtRI2c:106:104::/data_asys1/home/sys_asys:/sbin/sh
        :       
        :

1.2) /usr/lib/cron/cron.allow (on active node):

        :
        ora_asys
        :

1.3) /usr/lib/cron/at.allow (on active node):

        :
        ora_asys
        sys_asys
        :

1.4) cd /data_asys1/home; ls -ald (on active node):

        drwxr-xr-x   6 ora_asys oinstall ... ora_asys/
        drwxrwxr-x  10 sys_asys autosys  ... sys_asys/

        HINT: /data_asys1 goes with the asys package.

1.5) /etc/cmcluster/asys_sv1_prod/asys_sv1_prod.cntl (on all nodes):

        :
        :

        function customer_defined_run_cmds
        {
                # ADD customer defined run commands.

                :
                :

                /opt/edrc/bin/cronhandler -a load \
                  -s /data_asys1/pkg_cron -u /data_asys1/home

                test_return 51
        }

        :
        :


        function customer_defined_halt_cmds
        {
                # ADD customer defined halt commands.

                /opt/edrc/bin/cronhandler -a save \
                  -s /data_asys1/pkg_cron -u /data_asys1/home

                :
                :

                test_return 52
        }

        :
        :

1.6) Initial steps to initiate the daemon to work (on active node):

Save the current crontab definitions and at jobs to disk:

/opt/edrc/bin/cronhandler -a save -s /data_asys1/pkg_cron -u /data_asys1/home

        cronhandler - handle cron and at entries in a cluster environment, by Chr. Walther

        stop cronhandler daemon for '/data_asys1/pkg_cron' ...(not running)... done.
        save crontab and at entries ...
                user: asys_sv1 ...
                        clear old cron/at saves ... done.
                        disable cron execution ... done.
                        save at jobs ...
                        done.
                        disable at execution ... done.
                done.
                user: ora_sys ...
                        clear old cron/at saves ... done.
                        save cron entries ... done.
                        remove cron entries ... done.
                        disable cron execution ... done.
                        save at jobs ...
                                save at job 1189778400.a ... done.
                                remove at job 1189778400.a ... done.
                        done.
                        disable at execution ... done.
                done.
                user: sys_asys ...
                        clear old cron/at saves ... done.
                        disable cron execution ... done.
                        save at jobs ...
                                save at job 1189778500.a ... done.
                                remove at job 1189778500.a ... done.
                                save at job 1189779100.a ... done.
                                remove at job 1189779100.a ... done.
                        done.
                        disable at execution ... done.
                done.
                clean up remaining saves (corpses) ...
                done.
                restart cron ...(wait 5 seconds)... done.
        done.

Immediately load the saved crontab definitions and at jobs from disk back into the system:

/opt/edrc/bin/cronhandler -a load -s /data_asys1/pkg_cron -u /data_asys1/home

        cronhandler - handle cron and at entries in a cluster environment, by Chr. Walther

        load crontab and at entries ...
                asys_sv1 ...
                        cron usage not authorized
                        at usage not authorized
                done.
                ora_sys ...
                        enable cron execution ... done.
                        load cron entries ... done.
                        enable at execution ... done.
                        load at jobs ...
                                load at job 1189778400.a ... done.
                        done.
                done.
                sys_asys ...
                        cron usage not authorized
                        enable at execution ... done.
                        load at jobs ...
                                load at job 1189778500.a ... done.
                                load at job 1189779100.a ... done.
                        done.
                done.
                restart cron ...(wait 5 seconds)... done.
        done.
        start cronhandler daemon for '/data_asys1/pkg_cron' ...(PID=18790)... done.

From now on the cronhandler daemon writes crontab definitions and defined at jobs in a regular interval to disk and no manual interventions are needed. The correct stop and start is handled via the MC/ServiceGuard control script ( /etc/cmcluster/asys_sv1_prod/asys_sv1_prod.cntl ).

 

SEE ALSO

edrcintro(1), osid(3), cron(1m), at(1), crontab(1), cronhandler.cfg(4),
Managing MC/ServiceGuard, March 2002, Hewlett-Packard Company, Part No: B3936-90055"

 

NOTES

Currently cronhandler runs on HP-UX ( tested on 11.00 and 11.11 ), Linux ( tested on RedHat 7.2 ) Solaris ( tested on SunOS 5.6 ). Enhancements to support other operating systems might be realized on request (please ask the author).

In an earlier version of cronhandler a root crontab entry was needed to write the crontab definitions and the at jobs to disk - this is no longer the case. Eventually existing /opt/edrc/bin/cronhandler -a write ... calls are ignored and do not influence the cronhandler. To avoid logfile entries, the old crontab entries should be removed eventually.

Use cron.allow and at.allow to control crontab and at job definition.

 

BUGS

-

 

AUTHOR

cronhandler was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net .

 

COPYRIGHT

Copyright © 2008 Christian Walther

This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
OPTIONS
SIGNALS
EXIT STATUS
FILES
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 00:13:58 GMT, March 08, 2025