[root@ceshi scripts]# cat tomcat_logs.sh
#!/bin/bash
#tomcat logs cut scripts
#yanqingrong
logs_path="/application/tomcat/logs/"
logs_file="catalina.out"
[ -d ${logs_path} ] && cd ${logs_path}
[ -f ${logs_file} ] && cp ${logs_file} ${logs_file}$(date +%F -d "-1day")
echo " " > ${logs_file}
find ${logs_path} -type f -name "*.log" -mtime +20 |xargs rm -f
定时任务:
01 00 * * * /bin/sh /server/scripts/tomcat_logs.sh >/dev/null 2>&1