Skip to content

Instantly share code, notes, and snippets.

@abel533
Created September 5, 2019 02:30
Show Gist options
  • Save abel533/d91b1151eb9e0a59d544a1858ef9cf7e to your computer and use it in GitHub Desktop.
Save abel533/d91b1151eb9e0a59d544a1858ef9cf7e to your computer and use it in GitHub Desktop.
#!/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
JAVA_HOME=/usr/java/jdk1.8.0_91/
export JAVA_HOME
# 根据自己的路径改写CATALANA_HOME
CATALANA_HOME=/server/tomcat8/
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 {start|stop|restart}"
;;
esac
exit 0
@abel533
Copy link
Author

abel533 commented Sep 5, 2019

增加权限
chmod a+x /etc/init.d/tomcat
启动服务
service tomcat start
开机启动
/sbin/chkconfig tomcat on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment