tomcat 清理日志

clear_log.sh

#!/bin/bash
#clear tomcat logs #log size (1M bytes),if lt, clear
LOG_FILE_SIZE=1024000 #define logs location
logs=(/usr/local/tomcat/logs/catalina.out) for ff in "${logs[@]}";
do #file size
size=0
if [ -f $ff ]
then
#get file size
size=`ls -l $ff |awk '{print $5}'`
fi #judge
if [ "$size"0 -gt "$LOG_FILE_SIZE"0 ]
then
echo start clear: "$ff" , size= "$size"
true > $ff
fi done #finish clear
echo clear logs done!

  

vi /etc/crontab
HELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
30 * * * * root /bin/clear_log.sh
上一篇:非对话框程序创建组合框Groupbox


下一篇:SWIT2019无线通信和信息技术国际研讨会(上海)