鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 服务器相关 > 批处理 > >

清理tomcat

来源:互联网 作者:佚名 时间:2015-11-04 09:44
清理tomcat 无 #!/bin/bash#Program: #1.输入目录read -p "请输入要清理包含tomcat的目录:" dirif [ ${dir} == "" -o ! -d ${dir} ]; then echo "$dir 不存在" exit 1fidirList=$(find ${dir} -name catalina.sh)for binDir in $dirListdo fileName=$(echo $
清理tomcat <无>
#!/bin/bash
#Program:
 
#1.输入目录
read -p "请输入要清理包含tomcat的目录:" dir
if [ ${dir} == "" -o ! -d ${dir} ]; then
    echo "$dir 不存在"
    exit 1
fi


dirList=$(find ${dir} -name catalina.sh)
for binDir in $dirList
do
    fileName=$(echo ${binDir}| sed 's/\/bin\/catalina.sh$//g')
    echo ================clear ${fileName}==================
   
    logFileName=${fileName}/logs
    if [ ! -d $logFileName ]; then
      mkdir ${logFileName}
    fi 
   
    catalinaFileName=${logFileName}/catalina.out
    if [ ! -f $catalinaFileName ]; then
      touch ${catalinaFileName}
    fi

    cd ${logFileName}
    find .  -type f  ! -name catalina.out ! -name .  -exec rm -f {} \;
    echo ''>${catalinaFileName}
    echo ls ${logFileName}
    ls -l  ${logFileName}
    echo -e '\n\n'

    appbakFileName=${fileName}/appbak
    if [ -d $appbakFileName ]; then
         cd ${appbakFileName}
         ls -lt|sed -n '3,$p'|awk '{print $9}'|awk '{print "rm -rf",$1}'|sh
         echo ls ${appbakFileName}
         ls -l
         echo -e '\n\n'
    fi 

    tempFileName=${fileName}/temp
    if [ -d $tempFileName ]; then
         cd ${tempFileName}
         ls -lt|sed -n '3,$p'|awk '{print $9}'|awk '{print "rm -rf",$1}'|sh
         echo ls ${tempFileName}
         ls -l
         echo -e '\n\n'
    fi

done
网友评论
<