Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelhahn committed Aug 7, 2023
1 parent 4f21a2f commit 3318ff8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/30_Usage/20_Output.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ To detect outdated jobs see section for cronstatus.sh on the next page.

| value | type | description |
|--- |--- |--- |
| SCRIPTNAME | string | commandline of executed job; The value is taken from 1st parameter of cronwrapper commandline |
| SCRIPTNAME | string | commandline of executed job; The value is taken from 1st parameter of cronwrapper commandline |
| SCRIPTTTL | integer | TTL value: in how many minutes this cronjob wust be repeated? The value is taken from 2nd parameter of cronwrapper commandline |
| SCRIPTSTARTTIME | datetime | starting time of the cronjob as time and (after comma) as unix timestamp; eg. `2022-09-22 09:48:58, 1663832938`|
| SCRIPTLABEL | string | label that will be part of the flag file and the log file name in the output directory. By default it is generated but you can override it with a 3rd parameter in cronwrapper commandline |
| SCRIPTPROCESS | integer | process id |
| JOBEXPIRE | integer | Unix timestamp when the job is expired. t is calculated by starttime plus TTL |
| SCRIPTENDTIME | datetime | ending time of the cronjob as time and (after comma) as unix timestamp; eg. `2022-09-22 09:48:12, 1663832938`|
| SCRIPTEXECTIME | string | Needed time for execution in seconds as human readable time; the delta of endtime - starttime |
| SCRIPTEXECTIME | string | Needed time for execution in seconds as human readable time; the delta of endtime - starttime; the time for execution of hooks is excluded |
| SCRIPTRC | integer | returncode of the executed commandline |
| SCRIPTOUT | string | Output of the executed command. This value can be repeated in the log on multiline outputs

Expand Down
44 changes: 33 additions & 11 deletions docs/30_Usage/50_Hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,36 @@ Their order for execution is alphabetic (by using the sort command). Suggestion
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/*)|
| 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|
| OUTFILE | {string} | filename of the still running cronjob (for after/*/*); you can grep its content eg. "^SCRIPTOUT=" (see Output) |
| 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/*)|

## Example

### Send an email if a job failed

Remark:
To send an email you need to install a mailer like sendmail or postfix locally and configure it to be able to send trusted emails via your smtp gateway.

Create a script as root eg. `hooks/after/on-error/send_email.sh`.
Make it executable `chmod 0755 hooks/after/on-error/send_email.sh`

Content of *send_email.sh*:

```shell
#!/bin/bash

[email protected]
SUBJECT="Cronjob on ${MYHOST} - ${LABELSTR} failed with rc=${rc}"

cat "${OUTFILE}" | mail -s "${SUBJECT}" ${TO}
```

0 comments on commit 3318ff8

Please sign in to comment.