先配置好环境变量$TOMCAT_HOME
在/etc/init.d/目录下新建文件tomcat,输入如下内容:
#! /bin/sh
# This shell script enables the automatic use of tomcat
#
# Author: liuxuanyu<neverend06@163.com>
#
RETVAL=0
start() {
echo -n "Tomcat Starting..."
echo
$TOMCAT_HOME/bin/startup.sh
}
stop() {
echo -n "Tomcat Stop..."
echo
$TOMCAT_HOME/bin/shutdown.sh
}
restart() {
echo -n "Tomcat restart..."
echo
stop
start
}
case "$1" in
start)
start;;
stop)
stop;;
restart)
restart;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
使用方法:
sudo /etc/init.d/tomcat start
sudo /etc/init.d/tomcat stop
sudo /etc/init.d/tomcat restart