Tomcat:在centos中做成自启动服务

# 创建一个启动脚本文件,脚本内容见下
vi /etc/init.d/tomcat
#!/bin/bash
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
# processname: tomcat
# description: tomcat is a j2se server
# chkconfig: – 85 15
# description: Start up the Tomcat servlet engine.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo -e "atomcat: unable to locate functions lib. Cannot continue."
exit -1
fi
RETVAL=$?
CATALINA_HOME="/app/tomcat8/website-8080"
case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit $RETVAL
#增加执行权限
chmod 751 /etc/init.d/tomcat
#添加成服务
chkconfig --add tomcat
#设置为自启动
chkconfig tomcat on
#启动服务
service tomcat start
#停止服务
service tomcat stop
原文地址:https://www.cnblogs.com/huiy/p/8352088.html