From 958257798bb5fc825b9c243c785bb130efaef50f Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Mon, 12 Jun 2023 22:20:00 +0200 Subject: [PATCH] Rotate cronscripts logs Configurable per variable (override in local vars file), we keep (by default) only 60 days --- config/common/variables | 3 +++ config/debian/cronscript | 3 +++ 2 files changed, 6 insertions(+) diff --git a/config/common/variables b/config/common/variables index b9c600ff..da11b63e 100644 --- a/config/common/variables +++ b/config/common/variables @@ -35,6 +35,9 @@ PATH=${masterdir}:${PATH} # By default, add no timestamps to stage logs TIMESTAMP=false +# How many days of logfiles to keep? +declare -r logkeep=${logkeep:-60} + declare -r HOSTNAME=$(hostname -s) # where do we want mails to go? For example log entries made with error() diff --git a/config/debian/cronscript b/config/debian/cronscript index d9bc00ee..7588fd4a 100755 --- a/config/debian/cronscript +++ b/config/debian/cronscript @@ -287,6 +287,9 @@ function laststeps() { # and ensure its no longer used exec > "$logdir/after${PROGRAM}.log" 2>&1 + # Rotate out old logfiles + find ${logdir}/${PROGRAM}_*.log.bz2 -mtime +${logkeep} -delete + # Now, at the very (successful) end of this run, make sure we remove # our stage files, so the next script run will do it all again. if [[ ${successval} -eq 0 ]]; then -- GitLab