日志备份
应用日志备份脚本
#!/bin/bash baklogdir="/home/systembak" [ ! -d ${baklogdir} ] && mkdir -p ${baklogdir} files=`find /usr/local/logs/ -name '*log.*[0-9]' -mtime -1` for i in `echo $files` do name1=`basename $i | awk -F. {'print $1"."$2'}` dir1=`dirname $i` dir2=`dirname $i | awk -F/ {'print $5'}` logtime=`stat $i | grep Modify |awk {'print $2 "-" $3'} | awk -F. {'print $1'}` #mkdir /home/systembak/ zip /home/systembak/$name1.$logtime.$dir2.zip $i 1>/dev/null #rename $i $dir1\/$name1.$logtime.log $i done ##删除90天之前的日志 find /home/systembak/ -mtime +90 -name "*.log*" -exec rm -rf {} \;