summaryrefslogtreecommitdiffstats
path: root/linhes/linhes-system/lh_log_care.cron
blob: ace0534d47c011cc5f0ea8845e24b2fcb60c8b05 (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 +6 \( ! -iname "*.gz" \) -exec gzip -9 {} \;