1 thedate=`date +%Y-%m-%d_%H:00` 2 predate=`date +%Y-%m-%d_%H:00 --date="-3 day"` 3 4 rmfile="/www/server/tomcat/logs/catalina-daemon.${predate}.out" 5 outfile="/www/server/tomcat/logs/catalina-daemon.out" 6 if [ -f ${rmfile} ];then 7 rm -f ${rmfile} 8 echo "删除文件:[$rmfile] Successful" 9 fi 10 11 if [ -f ${outfile} ];then 12 cp ${outfile} /www/server/tomcat/logs/catalina-daemon.${thedate}.out 13 echo "分割文件:[$outfile] Successful" 14 echo "" > ${outfile} 15 echo "清空文件:[$outfile] Successful" 16 fi