每天晚上11点50切割日志文件,同时删除超过30天的日志
# vi log.sh
<pre name="code" class="html">#!/bin/bash log_path=/doiido/apps/tomcat/logs d=`date +%Y-%m-%d` d90=`date -d'30 day ago' +%Y-%m-%d` cd ${log_path} && cp catalina.out $log_path/cron/catalina.out.$d.log echo > catalina.out rm -rf $log_path/cron/catalina.out.${d90}.log
# chmod 777 /doiido/log.sh
# crontab -e
50 23 * * * sh /doiido/log.sh
时间: 2024-09-30 07:49:38