CentOS6上实现Tomcat8 service启动,并查看status

service配置脚本,“/etc/init.d/tomcat”,实现通过"service tomcat status " 查看tomcat状态,并输出PID,见脚本

# description: Tomcat Start Stop Restart Status
 
JAVA_HOME=/usr/share/jdk1.8.0_65
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/tomcat-8.5.14
 
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
status)
ps -ef | grep tomcat | grep bootstrap.jar |grep start  >>null
if [ $? -ne 0 ]
then
 echo "tomcat stoped"
else
 ps -ef | grep tomcat | grep bootstrap.jar |grep start | awk '{print "tomcat pid: "$2}'
 echo "tomcat is runing....."
fi

esac
exit 0

btw,别忘了给tomcat添加执行属性。

 

posted @ 2017-05-02 13:38  柒零壹  阅读(2641)  评论(0编辑  收藏  举报