#!/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 {} \;