首页 >
web >
tomcat
linux添加tomcat服务并设置开机启动
时间:2016-08-05 14:17:45 点击: 来源: 作者:
在开机启动目录建立相关项。 cd /etc/init.d
vi /etc/init.d/tomcat
以tomcat安装目录/usr/local/tomcat/为例,填入代码如下:
#!/bin/sh #chkconfig: 2345 10 90 # description: Starts and Stops the Tomcat ...
在开机启动目录建立相关项。
cd /etc/init.d
vi /etc/init.d/tomcat
以tomcat安装目录/usr/local/tomcat/为例,填入代码如下:
#!/bin/sh
#chkconfig: 2345 10 90
# description: Starts and Stops the Tomcat daemon.
##############################################
#Startup script for Tomcat on Linux
#filename tomcat.sh
#Make sure the java and the tomcat installation path has been added to the PATH
JAVA_HOME=/usr/java/jdk1.8.0_77
CATALINA_HOME=/usr/local/tomcat
export JAVA_HOME
export CATALINA_HOME
###############################################
start_tomcat=/usr/local/tomcat/bin/startup.sh
stop_tomcat=/usr/local/tomcat/bin/shutdown.sh
start() {
echo -n "Starting tomcat: "
${start_tomcat}
echo "tomcat start ok."
}
stop() {
echo -n "Shutting down tomcat: "
${stop_tomcat}
echo "tomcat stop ok."
}
# See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
其中:JAVA_HOME=/usr/java/jdk1.8.0_77 中的jdk版本请根据自己系统所安装版本,位置调整,方法为:
ls /usr/java/
给脚本权限:
chmod 755 tomcat
添加到服务:
chkconfig --add tomcat
开机启动项:
chkconfig --level 345 tomcat on
”您可通过以下微信二维码,赞赏作者“