#!/bin/bash BACKDIR=/backup/logs/`date +%F` CATDIR=/home/tomcat/apache-tomcat/logs BACKFILE=`find $CATDIR -type f -mtime +3|grep -v catalina.out` CESHI=`echo $BACKFILE|wc -l` LOGFILE=/home/lichuang/backup.log Backup (){ if [ $CESHI -le 1 ] then echo ========`date +%F`======= >>$LOGFILE echo $BACKFILE >>$LOGFILE exit 0 else mkdir -p $BACKDIR mv -f $BACKFILE $BACKDIR >>$LOGFILE if [ $? -eq 0 ] then tar zcf $BACKDIR.tar.gz $BACKDIR echo ===`date +%F` BACKUP_OK===>>$LOGFILE sleep 3 rm -fr $BACKDIR fi fi } Backup
时间: 2024-10-26 02:01:53