Tomcat服务启动脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Tomcat服务启动脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash source /usr/local/application/tomcat/.bash_profile TOMCAT_NAME=tomcat7 TOMCAT_HOME=/usr/local/application/tomcat/tomcat7 TOMCAT_PID=`ps -ef | grep ${TOMCAT_NAME} | grep -v "grep" | awk '{print $2}'` 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} is running,PID: ${TOMCAT_PID} \e[0m" ${TOMCAT_HOME}/bin/shutdown.sh echo -e "\e[1;32m ${TOMCAT_PID} killed \e[0m" kill -9 ${TOMCAT_PID} ${TOMCAT_HOME}/bin/startup.sh 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 fi } 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服务启动脚本的主要内容,如果未能解决你的问题,请参考以下文章
Centos开机自动执行shell脚本启动tomcat服务器