Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelhahn committed Mar 11, 2024
1 parent 52326c0 commit 1cc72b6
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 91 deletions.
1 change: 1 addition & 0 deletions docs/05_Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* ADDED: Support for `NO_COLOR=1`
* ADDED: emoji support (only if NO_COLOR is not 1 and is supported)
* UPDATE: enhanced output for `cronstatus.sh`: show a table with last executions (max. 10 per job)
* UPDATE: `cronstatus.sh` got a few cli parameter options
* UPDATE: renamed variables with prefix "CW_" (for cron wrapper)
* UPDATE: keep stats of returncodes and execution time for custom time (before: 4 days [fixed]; now: 14 days [can be configured with CW_KEEPDAYS])

Expand Down
34 changes: 34 additions & 0 deletions docs/10_Description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Introduction

Default Unix and linux cronjobs are quite basic stuff. Mostly you create
"simple, stupid" jobs without output ... that just run. Or should.

If you use a cronjob you need to hide the output otherwise the root user gets an
email. So if you generate the output and have many cronjobs then you need a
convention how to name your log files.

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 just adding a wrapper in front of your current command
breaks tons of limits! Suddenly a simple action opens so many possibilities.

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)
* cronlog-sync.sh - syncs logfiles to a central log server

To sync logfiles to a central log server there is script that detects new files in the logdir since the last sync.

## Requirements

Linux system with installed Bash.
Tested on CentOS, Debian, Manjaro, Ubuntu.

I would say it runs on every system with GNU Bash. Non-GNU Bash was not tested.
File renamed without changes.
File renamed without changes.
86 changes: 53 additions & 33 deletions docs/30_Usage/10_Cronwrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,51 +28,71 @@ Use -h to show a help:
```text
cronwrapper.sh -h
--------------------------------------------------------------------------------
|
A X E L S --x--
______ ________ |
| |.----.-----.-----. | | | |.----.---.-.-----.-----.-----.----.
| ---|| _| _ | | | | | || _| _ | _ | _ | -__| _|
|______||__| |_____|__|__| |________||__| |___._| __| __|_____|__|
|__| |__|
v 2.0
AXELS CRONWRAPPER
Puts control and comfort to cronjobs.
Puts control and comfort to your cronjobs.
source: https://github.com/axelhahn/cronwrapper
license: GNU GPL 3.0
📄 Source : https://github.com/axelhahn/cronwrapper
📗 Docs : https://www.axel-hahn.de/docs/cronwrapper/
📜 License: GNU GPL 3.0
--------------------------------------------------------------------------------
ERROR: missing parameters.
Showing help ...
####| ✨ SYNTAX |####
SYNTAX: ./cronwrapper.sh TTL COMMAND [LABEL]
./cronwrapper.sh TTL COMMAND [LABEL]
PARAMETERS:
TTL integer value in [min]
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
When using spaces or parameters then quote it.
Be strict: if your job is ok then exit wit returncode 0.
If an error occurs exit with returncode <> 0.
####| 🏷 PRAMETERS |####
LABEL optional: label to be used as output filename
If not set it will be detected from basename of executed command.
When you start a script with different parameters it is highly
recommended to set the label.
TTL integer value in [min]
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
10080 - 7 days
COMMAND command to execute
When using spaces or parameters then quote it.
Be strict: if your job is ok then exit wit returncode 0.
If an error occurs exit with returncode <> 0.
LABEL optional: label to be used as output filename
If not set it will be detected from basename of executed command.
When you start a script with different parameters it is highly
recommended to set the label.
REMARK:
You don't need to redirect the output in a cron config file. STDOUT and
STDERR will be fetched automaticly.
It also means: Generate as much output as you want and want to have to debug a
job in error cases.
OUTPUT:
The output directory of all jobs executed by ./cronwrapper.sh is
/var/tmp/cronlogs.
The output logs are parseble with simple grep command.
####| 📝 REMARK |####
You don't need to redirect the output in a cron config file. STDOUT and
STDERR will be fetched automaticly.
It also means: Generate as much output as you want and want to have to debug
a job in error cases.
####| 🗨 MORE TO SAY |####
The output directory of all jobs executed by ./cronwrapper.sh is
/var/tmp/cronlogs.
The output logs are parseble with simple grep command.
You can run ./cronstatus.sh to get a list of all cronjobs and
its status. Based on its output you can create a check script for your
server monitoring.
You can sync all logfiles of all cronjobs to a defined server using
./cronlog-sync.sh
MONITORING:
You can run ./cronstatus.sh to get a list of all cronjobs and its
status. Check its source. Based on its logic you can create a check script for
your server monitoring.
```

# Replace existing Cronjobs
Expand Down
59 changes: 44 additions & 15 deletions docs/40_More/30_Cronstatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,55 @@ By starting the helper script

```txt
> cronstatus.sh -h
____________________________________________________________________________________
______________________________________________________________________________
AXELS CRONWRAPPER
Jobstatus of cronjobs on 🖥 linux-pc
v 2.0
______________________________________________________________________________
Show the status of all local cronjobs that use the cronwrapper or a single job
by giving its logfile as parameter.
This script is part of Axels cronwrapper.
📗 Docs : https://www.axel-hahn.de/docs/cronwrapper/
📜 License: GNU GPL 3.0
####| ✨ SYNTAX |####
cronstatus.sh [OPTIONS] [LOGFILE|LABEL]
####| 🔧 OPTIONS |####
-h|--help show this help and exit.
-d|--nodetails hide detailed meta infos
-l|--nolast hide last executions
-o|--nooutput hide logfile output (when adding a param for logfile|label)
-r|--norunning hide running processes
-s|--short short status; sortcut for '-d -l -r'
####| 🏷 PARAMETERS |####
LOGFILE filename to show details of a single logfile
LABEL label of a job
CRONJOBS on [linux-pc]
______________________________________________________________________________/ v1.9
Default: without any logfile/ label you get a total overview of all
cronjobs.
SYNTAX: cronstatus.sh [OPTIONS|LOGFILE]
OPTIONS:
-h show this help and exit.
####| 🧩 EXAMPLES |####
PARAMETERS:
LOGFILE filename or label to show details of a single logfile
Default: without any logfile you get a total overview of all
cronjobs.
EXAMPLES:
cronstatus.sh
show total overview over all jobs
cronstatus.sh
show total overview over all jobs
cronstatus.sh /var/tmp/cronlogs/myjobfile.log
show output of a single job
cronstatus.sh /var/tmp/cronlogs/myjobfile.log
show output of a single job
```

Expand Down
33 changes: 0 additions & 33 deletions docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,3 @@ Free software and Open source.
📄 Source: <https://github.com/axelhahn/cronwrapper> \
📜 License: GNU GPL 3.0 \
📗 Docs: see [www.axel-hahn.de/docs](https://www.axel-hahn.de/docs/cronwrapper/)

## Introduction

Default Unix and linux cronjobs are quite basic stuff. Mostly you create
"simple, stupid" jobs without output ... that just run. Or should.

If you use a cronjob you need to hide the output otherwise the root user gets an
email. So if you generate the output and have many cronjobs then you need a
convention how to name your log files.

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 just adding a wrapper in front of your current command
breaks tons of limits! Suddenly a simple action opens so many possibilities.

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)
* cronlog-sync.sh - syncs logfiles to a central log server

To sync logfiles to a central log server there is script that detects new files in the logdir since the last sync.

## Requirements

Linux system with installed Bash.
Tested on CentOS, Debian, Manjaro, Ubuntu.
Binary file modified docs/images/rewrite_a_cronjob.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 19 additions & 10 deletions docs/style.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
patch css elements of daux.io blue theme
version 2022-12-04
version 2023-10-09
*/

:root {

/* Axels Overrides */
--color-text: #567;
--link-color: #37a;
--brand-color: var(--color-secondary);
--brand-background: var(--body-background);
Expand All @@ -24,6 +25,7 @@
/* Axels custom values */
--axel_bg-toc: var(--body-background);
--axel_bg-toc-head: #f8f8f8;
--axel_color-toc:#89a;

--axel_brand-background: none;
--axel_brand-pre-background: #8ce;
Expand All @@ -34,13 +36,13 @@
--axel_h1: #aaa;
--axel_h1-bg: none;
--axel_h1-bottom: 3px solid none;
--axel_h2: #27a;
--axel_h2: #123;
--axel_h2-bg: #fafafa;
--axel_h2-bottom: 2px solid #8ce;
--axel_h3: #838;
--axel_h3: #468;
--axel_h3-bg: none;
--axel_h3-bottom: 1px solid #ddd;
--axel_h4: #c74;
--axel_h4: #8ac;
--axel_h4-bg: none;
--axel_h4-bottom: 1px dashed #ddd;

Expand All @@ -59,7 +61,7 @@
.dark {

/* Axels Overrides */
--color-text: #c0c0c0;
--color-text: #789;
--link-color: #6bd;

--brand-color: var(--color-text);
Expand Down Expand Up @@ -87,13 +89,15 @@
--axel_h1: #777;
--axel_h1-bg: none;
--axel_h1-bottom: none;
--axel_h2: #27a;
--axel_h2: #666;
--axel_h2-bg: #282828;
--axel_h2-bottom: 2px solid #256;
--axel_h3: #838;
--axel_h3: #578;
--axel_h3-bg: none;
--axel_h3-bottom: 1px solid #333;
--axel_h4: #c74;
--axel_h4: #689;
--axel_h4-bg: none;
--axel_h4-bottom: 1px dashed #333;

Expand Down Expand Up @@ -171,9 +175,10 @@ article nav{border-top: var(--axel-article-nav-border-top); margin: 8em 0 5em;}
.optional{color:#888;}

div.hero{background: var(--axel_hero_bg);border-radius: 2em; padding: 5em 2em;text-align: center;}
div.hero h2{color: var(--color-text); background: none; _border: none; text-align: center; font-size: 300%; margin: 0 0 2em;}
div.hero h2{background: none; _border: none; text-align: center; font-size: 300%; margin: 0 0 2em;}
div.hero p.center{text-align: center;}


/* ---------- classes ---------- */


Expand All @@ -193,10 +198,11 @@ div.hero p.center{text-align: center;}

.s-content .TableOfContentsContainer h4{
background-color: var(--axel_bg-toc-head);
border-top-left-radius: 1em;
font-size: 1.1em;
border-top-left-radius: 0.7em;
font-size: 1.2em;
font-weight: bold;
margin: 0;
padding: 0;
padding: 0.3em 0.7em;
}

.TableOfContentsContainer__content {
Expand All @@ -208,6 +214,9 @@ ul.TableOfContents ul{
list-style-type: none;
padding-left: 1em;
}
ul.TableOfContents a {
color: var(--axel_color-toc);
}

.EditOn a::before{
content: '✏️ ';
Expand Down

0 comments on commit 1cc72b6

Please sign in to comment.