#!/bin/bash
#
# Init file for Apache Tomca8 server daemon
# chkconfig:235 65 37
# description:this is Apache Tomcat8 server daemon
# processname:tomcat8
# set JAVA_HOME
#set Apache Tomcat8 server path
tomcat8path=/data/fit/apache-tomcat-7.0.56/ #你的tomcat绝对路径
start()
{
cd $tomcat8path/bin
echo -n "Start fitTomCat:"
$tomcat8path/bin/catalina.sh start
}
stop()
{
echo -n "Stop fitTomCat:"
$tomcat8path/bin/catalina.sh stop
}
#do command
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Use :$0 {start|stop|restart}"
;;
esac
exit $RETVAL
之后把该文件(注意文件名称的重复)上传到 init.d 目录
cd /etc/init.d
之后给上传的文件 赋予 权限
chmod 777 fitTomcat
在之后新增服务
chkconfig --add fitTomcat
搞定
service fitTomcat restart 尝试一下吧