Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelhahn committed Apr 1, 2024
1 parent eb4047e commit acb849d
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 116 deletions.
30 changes: 20 additions & 10 deletions docs/60_Usage/20_Output.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,31 @@ axel@linux-pc /v/t/cronlogs> pwd
/var/tmp/cronlogs
axel@linux-pc /v/t/cronlogs> ls -1 *joblog*
linux-pc_joblog_Fri.done*
linux-pc_joblog_Sat.done*
linux-pc_joblog_Sun.done*
linux-pc_joblog_Thu.done*
linux-pc_joblog_Tue.done*
linux-pc_joblog_Wed.done*
linux-pc_joblog_20240317-Sun.done*
linux-pc_joblog_20240318-Mon.done*
linux-pc_joblog_20240319-Tue.done*
linux-pc_joblog_20240320-Wed.done*
linux-pc_joblog_20240321-Thu.done*
linux-pc_joblog_20240322-Fri.done*
linux-pc_joblog_20240323-Sat.done*
linux-pc_joblog_20240324-Sun.done*
linux-pc_joblog_20240325-Mon.done*
linux-pc_joblog_20240326-Tue.done*
linux-pc_joblog_20240327-Wed.done*
linux-pc_joblog_20240328-Thu.done*
linux-pc_joblog_20240329-Fri.done*
linux-pc_joblog_20240330-Sat.done*
linux-pc_joblog_20240331-Sun.done*
linux-pc_joblog_20240401-Mon.done*
```

Let's have look to it:

```txt
axel@linux-pc /v/t/cronlogs> head -3 linux-pc_joblog_Sun.done
job=restic-backup:host=linux-pc:start=1689458821:end=1689458905:exectime=84:ttl=60:rc=0
job=restic-backup:host=linux-pc:start=1689502021:end=1689502113:exectime=92:ttl=60:rc=0
job=restic-backup:host=linux-pc:start=1689505621:end=1689505708:exectime=87:ttl=60:rc=0
axel@linux-pc /v/t/cronlogs> head -3 linux-pc_joblog_20240401-Mon.done
job=restic-backup:host=linux-pc:start=1711922820:end=1711922937:exectime=117:ttl=60:rc=0
job=restic-backup:host=linux-pc:start=1711926420:end=1711926532:exectime=112:ttl=60:rc=0
job=restic-backup:host=linux-pc:start=1711973220:end=1711973399:exectime=179:ttl=60:rc=0
```

With a delimter `:` you see these data (values like in the job logs)
Expand Down
58 changes: 34 additions & 24 deletions docs/60_Usage/30_Cronstatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,42 @@ In this example I have 2 cronjobs using the cronwrapper and both are OK. In that

```text
> cronstatus.sh
____________________________________________________________________________________
______________________________________________________________________________
CRONJOBS on [www.example.com]
______________________________________________________________________________/ v1.7
--- /var/tmp/cronlogs/www.example.com_scheduler.sh.log
command : /opt/imlbackup/client/scheduler.sh
last start: 2022-01-12 11:45:01, 1641984301
returncode: 0 OK
duration : 0 s
ttl : 5 min OK
expires : 1641985021 2022-01-12 11:57:01 OK
CHECK OK
--- /var/tmp/cronlogs/www.example.com_imlpgcleanup.log
command : /opt/imlpgcleanup/walarchivecleanup.sh -p /tmp -a 10
last start: 2022-01-12 04:12:01, 1641957121
returncode: 0 OK
duration : 0 s
ttl : 1440 - 24 h OK
expires : 1642047121 2022-01-13 05:12:01 OK
CHECK OK
AXELS CRONWRAPPER
Jobstatus of cronjobs on πŸ–₯ linux-pc
v 2.0
______________________________________________________________________________
..... βœ” OK: restic-backup
Command : /home/axel/skripte/iml-backup/backup.sh
Last start: 2024-04-01 21:07:00, 1711998420
Returncode: 0 OK
Duration : 241 s
Ttl : 60 min OK
Expires : 1712005620 2024-04-01 23:07:00 OK
Logfile : /var/tmp/cronlogs/linux-pc_restic-backup.log
Last executions:
Result Start time rc Execution time
--------- ------------------- --- ---------------
OK 2024-04-01 21:07:00 0 241 s
OK 2024-04-01 20:07:00 0 141 s
OK 2024-04-01 19:07:00 0 119 s
OK 2024-04-01 18:07:00 0 127 s
OK 2024-04-01 17:07:00 0 203 s
OK 2024-04-01 16:07:00 0 120 s
OK 2024-04-01 15:07:00 0 197 s
OK 2024-04-01 14:07:00 0 179 s
OK 2024-04-01 01:07:00 0 112 s
OK 2024-04-01 00:07:00 0 117 s
There is no running job.
____________________________________________________________________________________
JOBS: 1 .. RUNNING: 1 .. ERRORS: 0
JOBS: 1 .. RUNNING: 0 .. ERRORS: 0
```

Expand All @@ -108,10 +118,10 @@ If a job is currently running you get a shorter info block with the time how lon
____________________________________________________________________________________
CURRENTLY RUNNING JOBS:
--- for 2 min - /var/tmp/cronlogs/my-laptop_iml-backup.log.running.NNNNN
--- ⏳ for 2 min - /var/tmp/cronlogs/linux-pc_restic-backup.log.running.NNNNN
command : /home/axel/skripte/client/backup.sh
last start: 2023-05-22 13:44:40, 1684755880
ttl : 1440
last start: 2024-06-01 22:07:01, ...
ttl : 60
OK - still running
(...)
```
Expand Down
106 changes: 76 additions & 30 deletions docs/70_More/40_Helper_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You need to source it in the beginning of your cronjob script.
```bash
#!/bin/bash
(...)
. /opt/cronwrapper/inc_cronfunctions.sh
. /opt/cronwrapper/inc_cronfunctions.sh || exit 1
(...)
```

Expand All @@ -18,71 +18,117 @@ This adds a variable rcAll and a few functions.
After sourcing inc_cronfunctions.sh you get a list of available function with `cw.help`.

```txt
HELP FOR CRONWRAPPER FUNCTIONS
HELP FOR CRONWRAPPER FUNCTIONS * v2.0
auto generated list of implemented cw.* functions
cw.cecho
colored echo output using color and reset color afterwards
param string color code ... see cw.color
param string text to display
Colored echo output using color and reset color afterwards
see also: cw.color
Example:
cw.cecho ok "Action was successful."
cw.cecho ok "Action was successful."
param string color code ... see cw.color
param string text to display
cw.color
set a terminal color by a keyword
param string keyword to set a color; one of reset | head|cmd|input | ok|warning|error
Set a terminal color by a keyword
Example:
color cmd
ls -l
color reset
cw.color cmd
ls -l
color reset
global integer $NO_COLOR value 1 means: no color please; see http://no-color.org/
param string keyword to set a color; one of reset | head|cmd|input | ok|warning|error
cw.emoji
Show a given emoji if its display is supported
Example
echo $( cw.emoji "πŸ“œ" )License: GNU GPL 3.0
global integer $NO_COLOR value 1 means: no color please; see http://no-color.org/
param string emoji to show
param string alternative text for NO_COLOR=1 output
cw.exec
execute a given command, show return code (and add it to final exit code)
param string(s) command line to execute
Execute a given command, show return code (and add it to final exit code)
param string command line to execute
cw.fetchRc
get last exitcode and store it in global var $rc
Get last exitcode and store it in global var $rc
no parameter is required
global integer $rcAll sum of retuncodes of all commands
cw.help
show help for available cw.* functions
Show help for available cw.* functions
no parameter required
cw.helpsection
Print a headline for a help section
param string emoji
param string headline text
cw.lock
verify locking and create one if no active lock was found
param string optional: string to create sonething uniq if your script can
Verify locking and create one if no active lock was found
see also: cw.lockstatus, cw.unlock
global string $CW_lockfile filename of the lockfile
param string optional: string to create sonething uniq if your script can
be started with multiple parameters
see cw.lockstatus, cw.unlock
cw.lockstatus
check status of locking
Check status of locking
exit code is 0 if locking is active
see also: cw.lock, cw.unlock
Example: if cw.lockstatus; then echo Lock is ACTIVE; else echo NO LOCKING; fi
see cw.lock, cw.unlock
global string CW_lockfile filename for locking
cw.quit
quit script with showing the total exitcode.
Quit script with showing the total exitcode.
global integer $rcAll sum of retuncodes of all commands
no parameter is required
cw.randomsleep
sleep for a random time
Sleep for a random time
param integer time to randomize in sec
param integer optional: minimal time to sleep in sec; default: 0
Example:
cw.randomsleep 60 sleeps for a random time between 0..60 sec
cw.randomsleep 60 30 sleeps for a random time between 30..90 sec
cw.timer
get time in sec and milliseconds since start
Get time in sec and milliseconds since start
global integer $CW_timer_start start time in sec
no parameter is required
cw.unlock
remove an existing locking
Remove an existing locking
no parameter is required
see cw.lock, cw.lockstatus
see also: cw.lock, cw.lockstatus
global string CW_lockfile filename for locking
```

Expand Down
104 changes: 71 additions & 33 deletions docs/70_More/60_Cronlog-Sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,77 @@ Use -h to show a help:

```text
> ./cronlog-sync.sh -h
____________________________________________________________________________________
SYNC LOCAL LOGS OF www.example.com
______________________________________________________________________________/ v1.5
HELP:
This script syncs local cronlogs to a target.
It should be used as cronjob in /etc/cron.d/ and/ or triggered
whem any cronwrapper script was fisnished.
SYNTAX:
cronlog-sync.sh [OPTIONS]
PRAMETERS:
-f [integer] time in sec when to force symc without new logs
value 0 forces sync
current value: [3600]
-h show this help
-i [string] path to ssh private key file
current value: [/home/copy-cronlogs/.ssh/[email protected]]
-l [string] local log dir of cronjobs
current value: [/var/tmp/cronlogs]
-q be more quiet
-s [integer] sleep random time .. maximum is given value in seconds
-t [string] target dir (local or remote like rsync syntax)
current value: [[email protected]:/var/tmp/allcronlogs/www.example.com]
DEFAULTS:
see also /opt/cronwrapper/cronwrapper.cfg
EXAMPLES:
cronlog-sync.sh -s 20 -t [TARGET] wait max 20 sec before starting sync
cronlog-sync.sh -q -f 0 be more quiet and force sync (0 sec)
______________________________________________________________________________
AXELS CRONWRAPPER
SYNC LOCAL LOGS OF πŸ–₯ linux-pc
v 2.0
______________________________________________________________________________
This script syncs local cronlogs to a target.
It should be used as cronjob in /etc/cron.d/ and/ or triggered
whem any cronwrapper script was fisnished.
This script is part of Axels Cronwrapper.
πŸ“— Docs : https://www.axel-hahn.de/docs/cronwrapper/
πŸ“œ License: GNU GPL 3.0
####| ✨ SYNTAX |####
cronlog-sync.sh [OPTIONS]
####| πŸ”§ OPTIONS |####
-f [integer] time in sec when to force symc without new logs
value 0 forces sync
current value: [3600]
-h show this help
-i [string] path to ssh private key file
current value:
[/root/.ssh/[email protected]]
-l [string] local log dir of cronjobs
current value:[/var/tmp/cronlogs]
-q be more quiet
-s [integer] sleep random time .. maximum is given value in seconds
-t [string] target dir (local or remote like rsync syntax)
current value:
[[email protected]:/var/tmp/allcronlogs/linux-pc]
####| πŸ”· DEFAULTS |####
see ./cronwrapper.cfg
####| 🧩 EXAMPLES |####
cronlog-sync.sh -s 20 -t [TARGET]
Wait max. 20 sec before starting sync to a custom target
cronlog-sync.sh -q -f 0
be more quiet and force sync (0 sec)
####| ❌ EXITCODES |####
0 OK. Action ended as expected. No sync needed or sync was done.
1 Missing parameter
2 Invalid option
3 No FQDN was found in hostname
4 No target was set in configuration
5 Target is still example.com
6 Logdir with files to sync was not found
7 rsync of local logs to target failed
```

Expand Down
Loading

0 comments on commit acb849d

Please sign in to comment.