Skip to content

Commit

Permalink
update help text and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelhahn committed Mar 9, 2022
1 parent 3ce4a2f commit e0b1d51
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 24 deletions.
6 changes: 4 additions & 2 deletions cronwrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ $line1
$1
SYNTAX: $0 TTL COMMAND [LABEL]
PARAMETERS:
TTL integer value in [min]
This value how often your cronjob runs. It is used to verify
This value says how often your cronjob runs. It is used to verify
if a cronjob is out of date / does not run anymore.
As a fast help a few values:
60 - 1 hour
1440 - 1 day
COMMAND command to execute
When using spaces or parameters then quote it.
Expand Down
53 changes: 33 additions & 20 deletions docs/20_Usage/10_Cronwrapper.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
# Help
# Introduction

The cronwrapper.sh is a script to wrap your cronjob.

It does a few small and helpful things:

* The wrapper fetches any output of stdout + stderr and creates a log file with a name based on the started script
(remark: you can override the naming with a 3rd parameter).
Do not try to keep silent anymore: write as many output as you want!
And some more good news: Write the output in your cronscripts that you can understand the execution!
* The wrapper logs a few things by itself:
* the started command
* starting time
* ending time
* ... and if having them: the execution time
* the exitcode of the command/ script;
This means: be strict like all commands do! Write your cronjob script that
ends with exitcode 0 if it is successful and quit with non-zero if any
error occurs. Be strict with the exitcode to be able to monitor the cronjobs!
* The TTL value (parameter 2) generates a file with a timestamp. A check
script detects with it if a cronjob log is outdated
* all metadata and the output will be written in a log file with parsable

# Show help

Use -h to show a help:

Expand All @@ -22,7 +45,7 @@ SYNTAX: ./cronwrapper.sh TTL COMMAND [LABEL]
PARAMETERS:
TTL integer value in [min]
This value how often your cronjob runs. It is used to verify
This value says how often your cronjob runs. It is used to verify
if a cronjob is out of date / does not run anymore.
COMMAND command to execute
Expand Down Expand Up @@ -54,6 +77,10 @@ your server monitoring.

# Replace existing Cronjobs

I am sure you already have some cronjobs on your systems :-)

You don't need to rewrite anything - we add the wrapper only.

As an example ... if you have a daily cronjob like this starting at 3:12 am:

```bash
Expand Down Expand Up @@ -83,22 +110,8 @@ To test it immediately run con command line:
You may ask: And what is the difference now?
First: your task does the same thing(s) like before.

But what the additional wrapper does:
But we us a wrapper with its functions described on top.

* The wrapper fetches any output of stdout + stderr and creates a log file with a name based on the started script
(remark: you can override the naming with a 3rd parameter).
Do not try to keep silent anymore: write as many output as you want! Write the output that you can understand the execution!
* The wrapper logs a few things by itself:
* the started command
* starting time
* ending time
* ... and if having them: the execution time
* the exitcode of the command/ script;
This means: be strinct like all commands do! Write your cronjob script that
ends with exitcode 0 if it is successful and quit with non-zero if any
error occurs. Be strict!
* The TTL value (parameter 2) generates a file with a timestamp. The check
script detects with it if a cronjob log is outdated
* all metadata and the output will be written in a log file with parsable
syntax! That's the key. Just using grep and cut you could verify all your jobs. But there is
an additional check script too: run cronstatus.sh
Run `cronstatus.sh`.

And then have a look to the generated files in `/var/tmp/cronlogs/`. And the next chapter.
8 changes: 7 additions & 1 deletion docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ Questions:
* How do you check if a job was successful? Just trust them? Watching each log? On each of your systems?
* How do you detect if the last job execution was successful but does not run anymore?

My simple approach: By simüly adding a wrapper in front of your current command
My simple approach: By simply adding a wrapper in front of your current command
breaks tons of limits! Suddenly a simple action opens so many posibilities.

This repository contains scripts and helpers for local cronjobs

* cronwrapper.sh - a wrapper script to call cronjob scripts
* inc_cronfunctions.sh - an include file that can be sourced in your bash scripts
* cronstatus.sh - ist shows status of all local cronjobs (and use cronwrapper.sh)

# Requirements

Linux system with installed bash.
Expand Down
8 changes: 7 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ Questions:
* How do you check if a job was successful? Just trust them? Watching each log? On each of your systems?
* How do you detect if the last job execution was successful but does not run anymore?

My simple approach: By simüly adding a wrapper in front of your current command
My simple approach: By simply adding a wrapper in front of your current command
breaks tons of limits! Suddenly a simple action opens so many posibilities.

This repository contains scripts and helpers for local cronjobs

* cronwrapper.sh - a wrapper script to call cronjob scripts
* inc_cronfunctions.sh - an include file that can be sourced in your bash scripts
* cronstatus.sh - ist shows status of all local cronjobs (and use cronwrapper.sh)

# Requirements

Linux system with installed bash.
Expand Down

0 comments on commit e0b1d51

Please sign in to comment.