标签:shell
#!/bin/bash
before_day=`date --date=-13day +%Y.%m%d`
after_day=`date --date=-7day +%m%d`
dir_path=‘/data/testlog/‘
backup_path=‘/data/backup_logs/‘
for dir_name in `ls ${dir_path}`
do
[ -d /data/backup_logs/${dir_name} ] || mkdir -p ${backup_path}${dir_name}
find ${dir_path}${dir_name} -type f -mtime +5 -mtime -14 | xargs tar -zcf ${dir_name}-${before_day}-${after_day}.tar.gz
mv ${dir_name}-${before_day}-${after_day}.tar.gz ${backup_path}${dir_name}
done
标签:shell
原文地址:http://blog.51cto.com/yht1990/2128929