From e0b1d51e6876663be7aa690985fbbabf4ac4b8f9 Mon Sep 17 00:00:00 2001 From: Axel Hahn Date: Wed, 9 Mar 2022 23:55:54 +0100 Subject: [PATCH] update help text and docs --- cronwrapper.sh | 6 ++-- docs/20_Usage/10_Cronwrapper.md | 53 ++++++++++++++++++++------------- docs/_index.md | 8 ++++- readme.md | 8 ++++- 4 files changed, 51 insertions(+), 24 deletions(-) diff --git a/cronwrapper.sh b/cronwrapper.sh index 64ccdac..4888130 100755 --- a/cronwrapper.sh +++ b/cronwrapper.sh @@ -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. diff --git a/docs/20_Usage/10_Cronwrapper.md b/docs/20_Usage/10_Cronwrapper.md index 5da82e6..8d72526 100644 --- a/docs/20_Usage/10_Cronwrapper.md +++ b/docs/20_Usage/10_Cronwrapper.md @@ -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: @@ -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 @@ -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 @@ -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. \ No newline at end of file diff --git a/docs/_index.md b/docs/_index.md index bb14050..699bb1d 100644 --- a/docs/_index.md +++ b/docs/_index.md @@ -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. diff --git a/readme.md b/readme.md index f11a483..3443fc9 100644 --- a/readme.md +++ b/readme.md @@ -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.