From b5747878f21c776f6f9941b1f43ad662a84bb955 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 22 Dec 2014 10:38:46 -0500 Subject: [PATCH] JBAS-258 syslog file cleanup options Signed-off-by: Bill Erickson --- KCLS/misc-scripts/manage-log-files.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/KCLS/misc-scripts/manage-log-files.sh b/KCLS/misc-scripts/manage-log-files.sh index b8b8f2516a..420c308983 100755 --- a/KCLS/misc-scripts/manage-log-files.sh +++ b/KCLS/misc-scripts/manage-log-files.sh @@ -1,14 +1,35 @@ #!/bin/bash set -eu +# *_AGE values are stored as days +# Example: a compress value of "3" means compress files +# last modified more than 3 days ago. +COMPRESS_AGE=3 +DELETE_AGE=365 + +function usage { + cat < -d +USAGE + exit; +} + +while getopts "d:c:h" opt; do + case $opt in + c) COMPRESS_AGE=$OPTARG;; + d) DELETE_AGE=$OPTARG;; + h) usage; + esac +done; + # Delete all Evergreen log files that are older than one year, # except for the Apache access log and Evergreen activity log. -/usr/bin/find /var/log/evergreen -type f -ctime +365 \ +/usr/bin/find /var/log/evergreen -type f -ctime +$DELETE_AGE \ -not -name "ap_access*" -not -name "activity*" -delete # Compress Evergreen log files older than 3 days -/usr/bin/find /var/log/evergreen/ -type f -ctime +3 \ +/usr/bin/find /var/log/evergreen/ -type f -ctime +$COMPRESS_AGE \ -not -name "*bz2" -exec /bin/bzip2 {} \; -- 2.11.0