Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelhahn committed Aug 6, 2023
1 parent 250d57f commit 6115185
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cronwrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ------------------------------------------------------------

# ------------------------------------------------------------
Expand Down Expand Up @@ -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"
Expand All @@ -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
# ------------------------------------------------------------
Expand Down
19 changes: 18 additions & 1 deletion docs/30_Usage/50_Hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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/*)|

0 comments on commit 6115185

Please sign in to comment.