diff --git a/docs/60_Usage/20_Output.md b/docs/60_Usage/20_Output.md index 56a107a..c53f433 100644 --- a/docs/60_Usage/20_Output.md +++ b/docs/60_Usage/20_Output.md @@ -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) diff --git a/docs/60_Usage/30_Cronstatus.md b/docs/60_Usage/30_Cronstatus.md index 7d73148..8687ae5 100644 --- a/docs/60_Usage/30_Cronstatus.md +++ b/docs/60_Usage/30_Cronstatus.md @@ -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 ``` @@ -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 (...) ``` diff --git a/docs/70_More/40_Helper_functions.md b/docs/70_More/40_Helper_functions.md index ecb5ea0..e300869 100644 --- a/docs/70_More/40_Helper_functions.md +++ b/docs/70_More/40_Helper_functions.md @@ -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 (...) ``` @@ -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 ``` diff --git a/docs/70_More/60_Cronlog-Sync.md b/docs/70_More/60_Cronlog-Sync.md index 0e21993..764b6c8 100644 --- a/docs/70_More/60_Cronlog-Sync.md +++ b/docs/70_More/60_Cronlog-Sync.md @@ -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/id_rsa@logserver.example.com] - -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: [get-cronlogs@logserver.example.com:/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/id_rsa_get-cronlogs@cronlogviewer.example.com] + + -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: + [get-cronlogs@cronlogviewer.example.com:/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 ``` diff --git a/docs/style.css b/docs/style.css index 3b49ad2..059671e 100644 --- a/docs/style.css +++ b/docs/style.css @@ -1,7 +1,7 @@ /* patch css elements of daux.io blue theme - version 2023-10-09 + version 2024-04-01 */ @@ -19,12 +19,20 @@ --sidebar-background:var(--body-background); --sidebar-border-color: none; - --sidebar-link-active-background: #e8f4f6; - --sidebar-link-active-background: #eee; + --sidebar-link-active-background: #f8f6f0; + + --table-border: #ddd; + --table-header-background: #d8e0e8; + --table-header-background: #d8e8e8; + --table-background-odd: #f8f7f5; + + --code-tag-background-color: #f0f4f8; + --code-tag-border-color: rgba(0,0,0,0.05); /* Axels custom values */ --axel_bg-toc: var(--body-background); --axel_bg-toc-head: #f8f8f8; + --axel_bg-toc-border: #8ce; --axel_color-toc:#89a; --axel_brand-background: none; @@ -37,9 +45,9 @@ --axel_h1-bg: none; --axel_h1-bottom: 3px solid none; --axel_h2: #123; - --axel_h2-bg: #fafafa; + --axel_h2-bg: none; --axel_h2-bottom: 2px solid #8ce; - --axel_h3: #468; + --axel_h3: #456; --axel_h3-bg: none; --axel_h3-bottom: 1px solid #ddd; --axel_h4: #8ac; @@ -50,11 +58,10 @@ --axel_img-border: 2px dashed #cbc; - --axel_nav-bg:#fcfcfc; + --axel_nav-bg: #fcfcfc; --axel_nav-buttomborder: #ddd; - --axel_pre-background: #f8f8f8; - --axel-th-background: #d0e0e8; + --axel_pre-background: #f8f7f5; --axel-article-nav-border-top: 0px dotted #ddd; } @@ -79,6 +86,7 @@ /* Axels custom values */ --axel_bg-toc: var(--body-background); --axel_bg-toc-head: #333; + --axel_bg-toc-border: #256; --axel_brand-background: none; --axel_brand-pre-background: #69a; @@ -109,7 +117,6 @@ --axel_nav-buttomborder: #555; --axel_pre-background: #bcc; - --axel-th-background: #203038; --axel-article-nav-border-top: 0px dotted #234; } @@ -146,29 +153,33 @@ a.Brand { .s-content{padding-top: 1em;} .s-content h1{background: var(--axel_h1-bg); color: var(--axel_h1); font-size: 200%; font-weight:bold; margin-bottom: 2em; margin-top: 0em; border-bottom: var(--axel_h1-bottom);} -.s-content h2{background: var(--axel_h2-bg); color: var(--axel_h2); font-size: 180%; font-weight:bold; margin-top: 4em; border-bottom: var(--axel_h2-bottom);} +.s-content h2{background: var(--axel_h2-bg); color: var(--axel_h2); font-size: 180%; font-weight:bold; margin-top: 4em; border-bottom: var(--axel_h2-bottom); padding: 0.2em} h2:first-of-type {margin-top: 0em;} -.s-content>h3{background: var(--axel_h3-bg); color: var(--axel_h3); font-size: 150%; font-weight:bold; margin-top: 3em; border-bottom: var(--axel_h3-bottom);} -.s-content>h4{background: var(--axel_h4-bg); color: var(--axel_h4); font-size: 130%; font-weight:bold; margin-top: 3em; border-bottom: var(--axel_h4-bottom);} +.s-content>h3{background: var(--axel_h3-bg); color: var(--axel_h3); font-size: 150%; font-weight:bold; margin-top: 5em; border-bottom: var(--axel_h3-bottom);} +.s-content>h4{background: var(--axel_h4-bg); color: var(--axel_h4); font-size: 130%; font-weight:bold; margin-top: 5em; border-bottom: var(--axel_h4-bottom);} .s-content img{border: var(--axel_img-border); border-radius: 1.5em; padding: 1em; margin: 1em 0;} .s-content pre{ background: var(--axel_pre-background); + margin: 0 -15px 20px; + padding-left: 15px; } /* FIX smaller fnt size in tables */ .s-content table { font-size: 1em; } -.s-content table th{ - background: var(--axel-th-background); -} .s-content h3 code{border: none; background: none; } article nav{border-top: var(--axel-article-nav-border-top); margin: 8em 0 5em;} .Pager li > a{padding: 1em 2em;} +.s-content code { + background: var(--code-tag-background-color); + border: 1px solid var(--code-tag-border-color); +} + /* ---------- classes ---------- */ .required{color:#a42;} @@ -178,10 +189,6 @@ div.hero{background: var(--axel_hero_bg);border-radius: 2em; padding: 5em 2em;te 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 ---------- */ - - /* ---------- TOC ---------- */ @media(min-width:1700px){ .TableOfContentsContainer{ @@ -199,6 +206,7 @@ div.hero p.center{text-align: center;} .s-content .TableOfContentsContainer h4{ background-color: var(--axel_bg-toc-head); border-top-left-radius: 0.7em; + border-bottom: 2px solid var(--axel_bg-toc-border); font-size: 1.2em; font-weight: bold; margin: 0;