diff options
author | Britney Fransen <brfransen@gmail.com> | 2013-11-13 16:11:18 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2013-11-13 16:11:18 (GMT) |
commit | 65d116fd70f48623c761c9375c31ab6ee6fcc179 (patch) | |
tree | 2fdd1ce64223bac7d5bd890a9dc002e9919618d0 /abs/core | |
parent | 404d8881490095229560d5820ea56e8ba0b7f172 (diff) | |
download | linhes_pkgbuild-65d116fd70f48623c761c9375c31ab6ee6fcc179.zip linhes_pkgbuild-65d116fd70f48623c761c9375c31ab6ee6fcc179.tar.gz linhes_pkgbuild-65d116fd70f48623c761c9375c31ab6ee6fcc179.tar.bz2 |
rsyslog: log_care.sh: keep backups based on number rather than time.
Diffstat (limited to 'abs/core')
-rw-r--r-- | abs/core/rsyslog/PKGBUILD | 4 | ||||
-rw-r--r-- | abs/core/rsyslog/log_care.sh | 22 |
2 files changed, 14 insertions, 12 deletions
diff --git a/abs/core/rsyslog/PKGBUILD b/abs/core/rsyslog/PKGBUILD index e8084ea..10ff5fa 100644 --- a/abs/core/rsyslog/PKGBUILD +++ b/abs/core/rsyslog/PKGBUILD @@ -3,7 +3,7 @@ pkgname=rsyslog pkgver=5.8.6 -pkgrel=9 +pkgrel=10 pkgdesc="An enhanced multi-threaded syslogd with a focus on security and reliability" url="http://www.rsyslog.com/" arch=('i686' 'x86_64') @@ -51,4 +51,4 @@ md5sums=('c46db0496066b82faf735bd4222208d7' 'a18bbcbb6ebdaa13a6ec6d9f3d9eb2da' '1a0cd4530dd5d1439456d5ae230574d9' 'df5cb090691db8640c489981ba3d0798' - 'f20c660ec9444613df0ad078944b31ec') + 'cd39e6edc1fcbbae2093c40c880e0079') diff --git a/abs/core/rsyslog/log_care.sh b/abs/core/rsyslog/log_care.sh index b0a774b..ced0f06 100644 --- a/abs/core/rsyslog/log_care.sh +++ b/abs/core/rsyslog/log_care.sh @@ -1,14 +1,16 @@ #!/bin/bash MYTH_RUN_STATUS=1 . /etc/profile -YEAR=`date +%Y` -LASTYEAR=$(($YEAR - 1)) -for DATE in $YEAR $LASTYEAR -do - echo "Compressing log files" - find /var/log/$DATE* -mtime +1 -exec gzip -9 {} \; + +BackupDir="/var/log/20*-*-*" +KeepBackups=14 +NumBackups=`ls -d $BackupDir | wc -l` + +if [[ $NumBackups > $KeepBackups ]]; then echo "Deleting old log files" - find /var/log/$DATE* -mtime +12 -exec rm -rf {} \; - echo "Deleting empty directories" - find /var/log/$DATE* -depth -type d -empty -exec rm -rf {} \; -done + numdel=$(($NumBackups-$KeepBackups)) + rm -rf `ls -d $BackupDir | head -$numdel` +fi + +echo "Compressing log files" +find $BackupDir -type f -mtime +2 \( ! -iname "*.gz" \) -exec gzip -9 {} \; |