当前位置: 代码迷 >> Web前端 >> linux 批量切割web日记shell
  详细解决方案

linux 批量切割web日记shell

热度:561   发布时间:2012-09-16 17:33:17.0
linux 批量切割web日志shell
服务器日志批量切割工具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