linux添加tomcat服务

一,脚本文件,编辑好后放在/etc/rc.d/init.d/下面
#!/bin/sh
#chkconfig: 2345 10 90
# description: Starts and Stops the Tomcat daemon.
#by jj
##############################################
#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/local/jdk                  #JDK安装目录
CATALINA_HOME=/usr/local/tomcat           #tomcat安装目录
export JAVA_HOME
export CATALINA_HOME


###############################################

start_tomcat=$CATALINA_HOME/bin/nohup_start.sh              #tomcat启动文件
stop_tomcat=$CATALINA_HOME/bin/shutdown.sh                  #tomcat关闭文件

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
二,后续服务:
1.给脚本权限:chmod 755 tomcat
2.添加到服务:chkconfig --add tomcat
3.开机启动项:chkconfig --level 345 tomcat on
4.在tomcat目录下编辑nohup_startup.sh(启动)文件
  rm -fr /usr/local/tomcat/bin/nohup.out
  nohup /usr/local/tomcat/bin/catalina.sh run > /usr/local/tomcat/bin/nohup.out &
5.给nohup_startup.sh执行权限。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值