赞
踩
- cat /root/logsize/log.dir
-
- /aplog/service/brm
- /aplog/service/epm
- /aplog/service/ifs
- /aplog/service/mes
- /aplog/service/quatrz
- /aplog/service/uas
- /aplog/web/bc
- /aplog/web/interface
- /aplog/web/opi
- cat /root/logsize/logsize.sh
-
- #!/bin/sh
- LOGDIR=`cat /root/logsize/log.dir`
- echo ${LOGDIR[@]}
-
- for LOG_DIR in ${LOGDIR[@]}
- do
- YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)
- TODAY=$(date +%Y-%m-%d)
- LOG_FILES=(`find $LOG_DIR -type f -name "*log.2*" -newermt "$YESTERDAY 00:00:00" ! -newermt "$TODAY 00:00:00"`)
- TOTAL_SIZE=0
- for file in ${LOG_FILES[@]}
- do
- size=$(du -m "$file" | awk '{print $1}')
- TOTAL_SIZE=$(($TOTAL_SIZE + size))
- done
- echo $LOG_DIR
- echo "$TOTAL_SIZE (M)"
- done
30 14 * * * /root/logsize/logsize.sh > /root/logsize/logsize.out.$(date +"\%Y\%m\%d")
每天统计一次前一天的日志量大小,并将每个目录的大小记录一份日志。
本测试脚本下,所有目录产生的日志均有固定格式,如每个目录不一样的话,需定义find语句中的name变量。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。