#!/bin/bash

DAY=`date +%Y-%m-%d`
YESTERDAY=`date -d last-day +%Y-%m-%d`

for i in mune
do
cat /usr/local/tomcat/tomcat-$i/logs/catalina.out > /usr/local/tomcat/tomcat-$i/logs/catalina.out.$YESTERDAY.back
> /usr/local/tomcat/tomcat-$i/logs/catalina.out

find /usr/local/tomcat/tomcat-$i/logs -name "host-manager.*" -mtime +7 -exec rm -rf {} \;
find /usr/local/tomcat/tomcat-$i/logs -name "localhost.*" -mtime +7 -exec rm -rf {} \;
find /usr/local/tomcat/tomcat-$i/logs -name "manager.*" -mtime +7 -exec rm -rf {} \;
find /usr/local/tomcat/tomcat-$i/logs -name "catalina.*" -mtime +7 -exec rm -rf {} \;
find /usr/local/tomcat/tomcat-$i/logs -name "localhost_access_log.*" -mtime +7 -exec rm -rf {} \;

done
