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添加執行屬性。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM