diff --git a/cronwrapper.sh b/cronwrapper.sh index 572d6ea..5293f31 100755 --- a/cronwrapper.sh +++ b/cronwrapper.sh @@ -41,7 +41,7 @@ # 2022-07-14 ahahn 1.24 added: deny multiple execution of the same job # 2022-07-16 ahahn 1.25 FIX: outfile of running job is a uniq file # 2022-07-16 ahahn 1.26 FIX: singlejob option was broken in 1.25 -# 2022-07-28 ahahn 1.27 add hooks +# 2022-08-06 ahahn 1.27 add hooks # ------------------------------------------------------------ # ------------------------------------------------------------ @@ -302,8 +302,6 @@ rc=none runHooks "before" >"${LOGFILE}" 2>&1 eval "${CALLSCRIPT}" >>"${LOGFILE}" 2>&1 rc=$? -runHooks "after" $rc >>"${LOGFILE}" 2>&1 - typeset -i iEnd iEnd=$(date +%s) w "SCRIPTENDTIME=$( date '+%Y-%m-%d %H:%M:%S' ), $iEnd" @@ -323,6 +321,8 @@ echo "job=${LABELSTR}:host=$MYHOST:start=$iStart:end=$iEnd:exectime=$iExectime:t chmod 777 "$JOBLOG" 2>/dev/null find $LOGDIR -name "${JOBBLOGBASE}*" -type f -mtime +4 -exec rm -f {} \; +runHooks "after" $rc >>"${LOGFILE}" 2>&1 + # ------------------------------------------------------------ # CLEANUP UND ENDE # ------------------------------------------------------------ diff --git a/docs/30_Usage/50_Hooks.md b/docs/30_Usage/50_Hooks.md index 5f5c0ac..497640a 100644 --- a/docs/30_Usage/50_Hooks.md +++ b/docs/30_Usage/50_Hooks.md @@ -35,4 +35,21 @@ After execution of the scripts of “on-ok” or “on-error” folder. Then add You can place multiple scripts into the subdirs on-ok|on-error|always. To be executed a file must have execution permissions. -Their order for execution is alphabetic (by using the sort command). Suggestion is to add numbers in front of a script name. \ No newline at end of file +Their order for execution is alphabetic (by using the sort command). Suggestion is to add numbers in front of a script name. + +## What variables you can have access.. + +Your hooks maybe want to access a few information to send a notification or whatever. +These data may help you to generate a message. + +| variable | type | description | +|-------------------|----------|---| +| `${CALLSCRIPT}` | {string} | executed command line | +| `${FINALOUTFILE}` | {string} | filename of the final logfile of the job to send as information| +| `${LABELSTR}` | {string} | label of the job| +| `${MYHOST}` | {string} | hostname| +| `${TTL}` | {int} | ttl value in minutes| +| `${iStart}` | {int} | Unix timestamp of the starting time| +| `${iEnd}` | {int} | Unix timestamp of the ending time (for after/*/*)| +| `${iExectime}` | {int} | execution time in seconds (for after/*/*)| +| `${rc}` | {int} | resturncode of the failed job (for after/on-error/*)|