Table of Contents
Config file
To create a custom configuration file copy cronwrapper.cfg.dist to cronwrapper.cfg.
For local running cronjobs and watching their status by cronstatus.sh there is no real need to touch it.
If you want to use a sync of a changed logfile with cronlog-sync.sh then you need to watch the lower section.
# -----------------------------------------------------------------------------
# CRONWRAPPER * config
# -----------------------------------------------------------------------------
# ----- shared values:
CW_LOGDIR=/var/tmp/cronlogs
# ----- for cronwrapper
# deny multiple execution of the same job? set 0 or 1
CW_SINGLEJOB=1
# directory with hooks
CW_HOOKDIR=./hooks
# permission on logfiles
# - for root only jobs: 0600
# - for mixed user: 0777
CW_LOGFILE_PERMS=777
# ----- for sync of local logs
CW_TOUCHFILE=lastsync
CW_TARGET=get-cronlogs@cronlogviewer.example.com:/var/tmp/allcronlogs/$( hostname -f )
CW_SSHKEY=/root/.ssh/id_rsa_get-cronlogs@cronlogviewer.example.com
# force rsync even if no change was found - time in sec
CW_SYNCAFTER=3600
# disallow hosts that have no domain in hostname -f; set 0 or 1
CW_REQUIREFQDN=0
# -----------------------------------------------------------------------------
For the execution of all cronjobs on the server there is just one variable to define a place where to store output files.
Variable | type | description |
---|---|---|
CW_LOGDIR | string | Ouput dir of all logfiles when using cronwrapper. It is used by status script and sync script to read data from here. Default: “/var/tmp/cronlogs” |
CW_SINGLEJOB | int | 0 or 1; 1=deny multiple execution of the same job (default) |
CW_HOOKDIR | string | Set an absolute directory to the hooks directory; use it if you use a created a softlink for the cronwrapper to /usr/local/bin and want to point to the real install directory; default: ./hooks; changing it is not needed |
CW_LOGDIR_PERMS | string | Set file permission on log directory; default: 777 |
CW_LOGFILE_PERMS | string | Set file permission on written logfiles; default: 777 |
On log files you can set permission on log directory and daily logfiles. These variables were introduces with v2.8. The very open default of 777 was used for backward compatibility. Try to run cronjobs as root or a sudo user to harden the file for a single user permissions.
- for root only jobs (or if all your jobs run with the same user):
0700
for directory and0600
for files - when mixed users execute cronwrapper: use
0777
for directory and files to allow writing all users updating its status in daily job logs.
For an optional rsync script to collect all logs of all servers on a central server (see Cronlog-Sync):
Variable | type | description |
---|---|---|
CW_TOUCHFILE | string | sync: filename of touch file to mark a timestamp of the last sync (created in in $CW_LOGDIR); eg. “lastsync” |
CW_TARGET | string | ssh target where to sync files from $LOGFILE with sshuser@targethost:/path Default: get-cronlogs@cronlogviewer.example.com:/var/tmp/allcronlogs/\$( hostname -f ) |
CW_SSHKEY | string | filename to ssh private key to connect passwordless to $TARGET |
CW_SYNCAFTER | int | time in sec; default: 3600 (1h); time before syncing the logdir even if it has noch change |
CW_REQUIREFQDN | int | 0 or 1; block sync if hostname -f has no FQDN |
Environment file
In a environment file you can set a pre defined shell environment for all your cronwrapper cronjobs. This is completely optional. Just keep in mind that the possibility exist if it is needed once.
To create a custom environment file copy cronwrapper.env.dist to cronwrapper.env. The file needs read permissions for all users (0644).
# -----------------------------------------------------------------------------
# CRONWRAPPER * environment
# -----------------------------------------------------------------------------
# export PATH=$PATH:...
# umask 0022
# -----------------------------------------------------------------------------