linux切割日志
1.vim log.sh,将文件复制进去
#!/bin/sh LOG_PATH=/home/tomcat/apache-tomcat-7.0.56/logs/ LOG_NAME=catalina.out LOG_NEW_NAME=catalina-`date +%Y-%m-%d`.log cp ${LOG_PATH}${LOG_NAME} ${LOG_PATH}${LOG_NEW_NAME} cat /dev/null >${LOG_PATH}${LOG_NAME} echo "tomcat-lo-server logs cat OK! "
2.配置定时任务 crontab -e,0 0 * * * sh /data/logs/log.sh 每天凌晨执行,
/bin/systemctl restart crond.service 刷新
3.vim catalina.sh
LOG_NEW_NAME=catalina-`date +%Y-%m-%d`.log