summaryrefslogtreecommitdiffstats
path: root/abs/core/rsyslog/log_care.sh
blob: ced0f06d5c0cceb0dc1459922b882f700d846ea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
MYTH_RUN_STATUS=1
. /etc/profile

BackupDir="/var/log/20*-*-*"
KeepBackups=14
NumBackups=`ls -d $BackupDir | wc -l`

if [[ $NumBackups > $KeepBackups ]]; then
    echo "Deleting old log files"
    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 {} \;