#!/bin/bash TOMCAT_NAME=tomcat7-application TOMCAT_HOME=/usr/local/application/${USER}/${TOMCAT_NAME} TOMCAT_PID=`ps -ef | grep ${TOMCAT_NAME} | grep -v "grep" | awk '{print $2}'` source /usr/local/application/${USER}/.bash_profile usage(){ echo -e "\e[1;32m Usage: $0 [ start | stop | status ] \e[0m" } TOMCAT_START(){ if [ "${TOMCAT_PID}" == "" ] then echo -e "\e[1;32m ${TOMCAT_NAME} is not running; start-up ${TOMCAT_NAME} \e[0m" ${TOMCAT_HOME}/bin/startup.sh else echo -e "\e[1;32m ${TOMCAT_NAME} (pid: ${TOMCAT_PID})is running... \e[0m" fi } TOMCAT_STOP(){ if [ "${TOMCAT_PID}" == "" ] then echo -e "\e[1;32m ${TOMCAT_NAME} is not running. \e[0m" else ${TOMCAT_HOME}/bin/shutdown.sh if [ "${TOMCAT_PID}" == "" ] then echo -e "\e[1;32m ${TOMCAT_NAME} service ceased to succeed. \e[0m" else sleep 5 kill -9 ${TOMCAT_PID} sleep 3 echo -e "\e[1;32m ${TOMCAT_NAME} service ceased to succeed. \e[0m" fi fi } #TOMCAT_RESTART(){ # TOMCAT_STOP # sleep 10 # TOMCAT_START #} TOMCAT_STATUS(){ if [ "${TOMCAT_PID}" == "" ] then echo -e "\e[1;32m ${TOMCAT_NAME} is not running. \e[0m" else echo -e "\e[1;32m ${TOMCAT_NAME} is running. \e[0m" fi } main(){ case $1 in start) TOMCAT_START ;; stop) TOMCAT_STOP ;; status) TOMCAT_STATUS ;; *) usage; esac } main $1;
Tomcat服务启动脚本
原创文章标签 Tomcat Shell 文章分类 运维
©著作权归作者所有:来自51CTO博客作者已注销的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:普通用户部署Tomcat

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
jenkins通过脚本启动java应用
本文简单简单介绍怎么通过jenkins来调用shell脚本启动java脚本。
html/xml shell