From: Frank Brehm Date: Wed, 20 Mar 2019 13:08:20 +0000 (+0100) Subject: Redirecting output into logfiles X-Git-Tag: 0.4.1~16 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=3d090cb405f9c62df6600d26f987490f0fe55333;p=pixelpark%2Fpp-admin-tools.git Redirecting output into logfiles --- diff --git a/sbin/cleanup-loghosts-hosts b/sbin/cleanup-loghosts-hosts index de09e85..2406c1c 100755 --- a/sbin/cleanup-loghosts-hosts +++ b/sbin/cleanup-loghosts-hosts @@ -7,6 +7,22 @@ if [[ ! -d "${HOSTS_DIR}" ]] ; then exit 5 fi +MY_LOG_DIR="${HOSTS_DIR}/zzz_cleanup_hostlogs" +if [[ ! -d "${MY_LOG_DIR}" ]] ; then + mkdir -m 0755 -p "${MY_LOG_DIR}" +fi + +i=0 +MY_LOG="${MY_LOG_DIR}/cleanup.$( date +'%Y-%m-%d' ).${i}.log" +ERR_LOG="${MY_LOG_DIR}/cleanup.$( date +'%Y-%m-%d' ).${i}.error.log" +while [[ -e "${MY_LOG}" || -e "${ERR_LOG}" ]] ; do + i=$(( $i + 1 )) + MY_LOG="${MY_LOG_DIR}/cleanup.$( date +'%Y-%m-%d' ).${i}.log" + ERR_LOG="${MY_LOG_DIR}/cleanup.$( date +'%Y-%m-%d' ).${i}.error.log" +done + +exec >> "${MY_LOG}" 2>> "${ERR_LOG}" + CUR_YEAR=$( date +'%Y' ) CUR_MONTH=$( date +'%m' ) @@ -209,11 +225,11 @@ compress_old_files() { echo echo "[$( my_date )]: Compressing files older than ${MIN_AGE_COMPRESS} days:" for fname in $( find "${HOSTS_DIR}" -type f -mtime +${MIN_AGE_COMPRESS} | \ - grep -vi '\.gz$' | head -n 1000 ) ; do + grep -vi '\.gz$' | head -n 10000 ) ; do if [[ -f "${fname}" ]] ; then echo " * '${fname}'" ls -l "${fname}" - gzip -v9 "${fname}" + gzip -9 "${fname}" ls -l "${fname}"* COMPRESSED_FILES=$(( $COMPRESSED_FILES + 1 )) fi