码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat开启自启动

时间:2019-01-11 10:15:41      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:dll   .bat   手动安装   lis   rtu   等级   授权   --   安装   

linux方式

#!/bin/bash
#chkconfig: 2345 11 91
#description: Starts and Stops the Tomcat daemon.
#by benjamin
##############################################
#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=/data/jdk1.8.0_172/                  #JDK安装目录
CATALINA_HOME=/data/tomcat/          #tomcat安装目录
export JAVA_HOME
export CATALINA_HOME


###############################################
start_tomcat=$CATALINA_HOME/bin/startup.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
chmod 755 /etc/rc.d/init.d/tomcat    #脚本授权
chkconfig --add /etc/rc.d/init.d/tomcat    #加入系统服务中
chkconfig tomcat on            #设定tomcat在各等级为on
chkconfig --list tomcat        #查看tomcat各个等级是否为on

 

windows方式:

Windows自启动(tomcat)

tomcat是安装版本,则在cmd输入service.msc找到

技术分享图片

 

tomcat解压版,通过startup.bat手动启动tomcat后会出现对话框,如果机器意外重启,tomcat还需要手动重启,比较麻烦。(解压版需要添加环境变量和添加服务名称手动安装版直接services.msc找到tomcat服务右键属性找到启动类型选择自动即可)(解压版需要添加环境变量手动安装不需要添加环境变量)

解决:将tomcat安装成系统服务,设置启动方式为自启动。

1.安装tomcat服务
进入tomcat的bin目录下,运行service.bat install安装
E:\tomcat_8083\bin>service.bat install
Installing the service Tomcat7 ...
Using CATALINA_HOME:    "E:\tomcat_8083"
Using CATALINA_BASE:    "E:\tomcat_8083"
Using JAVA_HOME:        "E:\Program Files (x86)\jdk1.7.0_25_X64"
Using JRE_HOME:         "E:\Program Files (x86)\jdk1.7.0_25_X64\jre"
Using JVM:              "E:\Program Files (x86)\jdk1.7.0_25_X64\jre\bin\server\jvm.dll"
Failed installing Tomcat7 service

如果提示Failed,可执行services.msc查看服务,看是否已存在Tomcat7服务,有则需要给新安装的服务指定其他名称,如下:

E:\tomcat_8083\bin>service.bat install Tomcat_8083
Installing the service Tomcat_8083 ...
Using CATALINA_HOME:    "E:\tomcat_8083"
Using CATALINA_BASE:    "E:\tomcat_8083"
Using JAVA_HOME:        "E:\Program Files (x86)\jdk1.7.0_25_X64"
Using JRE_HOME:         "E:\Program Files (x86)\jdk1.7.0_25_X64\jre"
Using JVM:              "E:\Program Files (x86)\jdk1.7.0_25_X64\jre\bin\server\j
vm.dll"
The service Tomcat_8083 has been installed.
提示安装成功!
如果需要删除服务,则使用
E:\tomcat_8085\bin>sc delete Tomcat7
[SC] DeleteService 成功

 

tomcat开启自启动

标签:dll   .bat   手动安装   lis   rtu   等级   授权   --   安装   

原文地址:https://www.cnblogs.com/luck666/p/10253644.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!