centos6配置tomcat8开机自启动脚本

时间:2022-06-01 22:05:11

1、vim /etc/init.d/tomcat

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/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/local/jdk1.8.0_161
export JAVA_HOME
CATALANA_HOME=/opt/apache-tomcat-8.5.24/
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

2、配置

?
1
2
3
chmod +x /etc/init.d/tomcat
chkconfig tomcat on
service tomcat start

总结

以上所述是小编给大家介绍的centos6配置tomcat8开机自启动脚本,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!

原文链接:https://my.oschina.net/u/1433006/blog/1615312