发布网友 发布时间:2022-04-24 17:56
共1个回答
热心网友 时间:2023-10-29 01:59
在/etc/init.d/下新建名为tomcat的脚本文件(vi /etc/init.d/tomcat),内容如下:#!/bin/bash # # tomcat startup script for the Tomcat server # # chkconfig: 345 80 20 # description: start the tomcat deamon # # Source function library . /etc/rc.d/init.d/functions prog=tomcat JAVA_HOME=/usr/java/jdk1.7 export JAVA_HOME CATALANA_HOME=/usr/local/tomcat export CATALINA_HOME case "$1" in start) echo "Starting Tomcat..." $CATALANA_HOME/bin/startup.sh ;; stop) echo "Stopping Tomcat..." $CATALANA_HOME/bin/shutdown.sh ;; restart) echo "Stopping Tomcat..." $CATALANA_HOME/bin/shutdown.sh sleep 2 echo echo "Starting Tomcat..." $CATALANA_HOME/bin/startup.sh ;; *) echo "Usage: $prog {startstoprestart}" ;; esac exit 0然后chkconfig tomcat on开启tomcat开机自启动。另外注意按照你tomcat的安装路径和jdk安装路径修改上面脚本中的路径参数