欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux 批量切割web日志shell

程序员文章站 2022-07-12 21:41:39
...
服务器日志批量切割工具shell

#!/bin/bash
#############################################
# at 2012-06-07
#############################################

logsPath=/web/logs/
workPath=$1

if [ -z ${workPath} ];then
   echo "参数异常"
   exit
fi

if [ ! -d logsPath ];then
  mkdir -p ${logsPath}
fi

# supported paths

for appPath in ${workPath}*; do
    ${appPath}/bin/shutdown.sh
    sleep 10
    cat ${appPath}/logs/catalina.out > ${appPath}/logs/catalina.out.`date +%Y%m%d`
    cat /dev/null > ${appPath}/logs/catalina.out
    echo "daily rotating for "${appPath}" successfully at "`date +%Y%m%d` >> ${logsPath}/catalina_log.txt

   ${appPath}/bin/startup.sh
done