Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 15546  / 1 Year ago, mon, november 28, 2022, 1:15:24

I installed tomcat servlet but I need to autostart it on boot. How to do that?


More From » automation

 Answers
4

You need to create an init script for tomcat and add it to the correct runlevel init script.



Advice adapted from here http://www.raibledesigns.com/tomcat/boot-howto.html



Create an init script /etc/init.d/tomcat/ for tomcat, changing the value for catalina home to the correct location:



#!/bin/bash
#
# tomcat
#
# chkconfig:
# description: Start up the Tomcat servlet engine.

# Source function library.
. /etc/init.d/functions


RETVAL=$?
CATALINA_HOME="/usr/apps/apache/tomcat/jakarta-tomcat-4.0.4"

case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
/bin/su tomcat $CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
/bin/su tomcat $CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac

exit $RETVAL


Then add a link to the rc5.d folder - /etc/rc5.d/



sudo ln -s /etc/init.d/tomcat /etc/rc5.d/S71tomcat

[#35055] Monday, November 28, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
anatta

Total Points: 326
Total Questions: 128
Total Answers: 96

Location: Jordan
Member since Sun, Jun 26, 2022
2 Years ago
anatta questions
Sun, Jul 17, 22, 07:13, 2 Years ago
Sun, Jun 6, 21, 12:17, 3 Years ago
Sat, Jun 12, 21, 20:43, 3 Years ago
Thu, Jan 13, 22, 20:49, 2 Years ago
Sat, Jun 5, 21, 05:39, 3 Years ago
;