diff options
Diffstat (limited to 'linhes/linhes-system/lh_log_care.cron')
-rwxr-xr-x | linhes/linhes-system/lh_log_care.cron | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/linhes/linhes-system/lh_log_care.cron b/linhes/linhes-system/lh_log_care.cron new file mode 100755 index 0000000..ace0534 --- /dev/null +++ b/linhes/linhes-system/lh_log_care.cron @@ -0,0 +1,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 {} \; |