tomcat 启动脚本
Posted 世事浮云
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat 启动脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash
#
#干掉运行中的tomcat results=把结果赋值给变量,可以保证命令上条执行完再执行下一条
#也可以用这句简单的代码按进程名kill: ps -ef | grep 进程名 | grep -v grep | awk ‘{print $2}‘ | xargs kill -9
results=`ps -ef|grep tomcat|grep -v grep|grep -v PPID|awk ‘{ print $2}‘`
echo -e ‘tomcat PID: ‘ ${results}
for i in ${results}
do
kill -9 $i
echo -e "Kill the tomcat process [ $i ]"
done
#
results=`ps -ef|grep tomcat|grep -v grep|grep -v PPID|awk ‘{ print $2}‘`
echo -e ‘tomcat PID: ‘ ${results}
#
#备份
dqsj=`date "+%Y-%m-%d_%H:%M:%S"`
results=`/bin/cp -rf /home/tomcat-7.0.85_6001/apps /home/gb/old/apps6001_${dqsj}`
echo -e ${results}
results=`/bin/cp -rf /home/tomcat-7.0.85_tslx/apps /home/gb/old/appstslx_${dqsj}`
echo -e ${results}
echo -e ‘back-up /tomcat/apps/ /home/gb/old/ OK‘
#
#清空tomcat日志
results=`/bin/rm -rf /home/tomcat-7.0.85_6001/logs/*`
echo -e ${results}
results=`/bin/rm -rf /home/tomcat-7.0.85_6002/logs/*`
echo -e ${results}
results=`/bin/rm -rf /home/tomcat-7.0.85_6003/logs/*`
echo -e ${results}
results=`/bin/rm -rf /home/tomcat-7.0.85_6004/logs/*`
echo -e ${results}
results=`/bin/rm -rf /home/tomcat-7.0.85_tslx/logs/*`
echo -e ${results}
echo -e ‘delete /tomcat/logs/* OK‘
#
#清空tomcat缓存
results=`/bin/rm -rf /home/tomcat-7.0.85_6001/work/Catalina/*`
echo -e ${results}
results=`/bin/rm -rf /home/tomcat-7.0.85_6002/work/Catalina/*`
echo -e ${results}
results=`/bin/rm -rf /home/tomcat-7.0.85_6003/work/Catalina/*`
echo -e ${results}
results=`/bin/rm -rf /home/tomcat-7.0.85_6004/work/Catalina/*`
echo -e ${results}
results=`/bin/rm -rf /home/tomcat-7.0.85_tslx/work/Catalina/*`
echo -e ${results}
echo -e ‘delete /tomcat/work/Catalina/* OK‘
#
#拷贝工程 节点6001
results=`/bin/cp -rf /home/gb/new/sfpt.war /home/tomcat-7.0.85_6001/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptpj.war /home/tomcat-7.0.85_6001/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptpu.war /home/tomcat-7.0.85_6001/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptmu.war /home/tomcat-7.0.85_6001/apps/`
echo -e ${results}
#
#拷贝工程 节点6002
results=`/bin/cp -rf /home/gb/new/sfpt.war /home/tomcat-7.0.85_6002/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptpj.war /home/tomcat-7.0.85_6002/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptpu.war /home/tomcat-7.0.85_6002/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptmu.war /home/tomcat-7.0.85_6002/apps/`
echo -e ${results}
#
#拷贝工程 节点6003
results=`/bin/cp -rf /home/gb/new/sfpt.war /home/tomcat-7.0.85_6003/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptpj.war /home/tomcat-7.0.85_6003/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptpu.war /home/tomcat-7.0.85_6003/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptmu.war /home/tomcat-7.0.85_6003/apps/`
echo -e ${results}
#
#拷贝工程 节点6004
results=`/bin/cp -rf /home/gb/new/sfpt.war /home/tomcat-7.0.85_6004/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptpj.war /home/tomcat-7.0.85_6004/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptpu.war /home/tomcat-7.0.85_6004/apps/`
echo -e ${results}
results=`/bin/cp -rf /home/gb/new/sfptmu.war /home/tomcat-7.0.85_6004/apps/`
echo -e ${results}
#
#拷贝工程 节点6005
results=`/bin/cp -rf /home/gb/new/sfpttslx.war /home/tomcat-7.0.85_tslx/apps/`
echo -e ${results}
#
echo -e ‘Copy /home/gb/new/ /tomcat/apps/ OK‘
#
#启动服务
results=`bash /home/tomcat-7.0.85_6001/bin/startup.sh`
echo -e ${results}
results=`bash /home/tomcat-7.0.85_6002/bin/startup.sh`
echo -e ${results}
results=`bash /home/tomcat-7.0.85_6003/bin/startup.sh`
echo -e ${results}
results=`bash /home/tomcat-7.0.85_6004/bin/startup.sh`
echo -e ${results}
results=`bash /home/tomcat-7.0.85_tslx/bin/startup.sh`
echo -e ${results}
echo -e ‘startup OK‘
#
results=`ps -ef|grep tomcat|grep -v grep|grep -v PPID|awk ‘{ print $2}‘`
echo -e ‘tomcat PID: ‘ ${results}
#
dqsj=`date "+%Y-%m-%d %H:%M:%S"`
echo -e ‘endTime ‘ ${dqsj}
#
以上是关于tomcat 启动脚本的主要内容,如果未能解决你的问题,请参考以下文章