The other day I installed a Tomcat server in Red Hat 8 for a client. The client had to reboot the server and couldn’t find a way to start it. I found a way to start Tomcat at boot time in Red Hat 8.

As usual, I needed to go for a walk around New York City in Brooklyn before taking on this one.

First, we need to create a startup script file for Tomcat in:

/etc/init.d

You can name this file tomcat and enter the below:

#!/bin/sh
export CATALINA_HOME="/usr/local/tomcat"
ERROR=0
case "$1" in
 start)
            echo $"Starting Tomcat"
            sh $CATALINA_HOME/bin/startup.sh
            ;;
 stop)
           echo $"Stopping Tomcat"
           sh $CATALINA_HOME/bin/shutdown.sh
           ;;
 restart)
           sh $CATALINA_HOME/bin/shutdown.sh
           sh $CATALINA_HOME/bin/startup.sh
            ;;
 *)
         echo $"Usage: $0 {start|stop|restart}"
 exit 1
 ;;
esac
exit $ERROR

Assigned the permissions below:

chomod 755 tomcat

Next, create a symbolic link of the tomcat script inside the rc.d directory:

ln -s /etc/init.d/tomcat /etc/rc.d/rc6.d/K24tomcat 
ln -s /etc/init.d/tomcat /etc/rc.d/rc0.d/K28tomcat
ln -s /etc/init.d/tomcat /etc/rc.d/rc3.d/S80tomcat
ln -s /etc/init.d/tomcat /etc/rc.d/rc2.d/S81tomcat
ln -s /etc/init.d/tomcat /etc/rc.d/rc5.d/S81tomcat

Go ahead and reboot your server and see if Tomcat starts automatically.

You can always contact me if you have any questions. Also, remember to visit my ITPro Helper shop where I created unique T-Shirts and coffee mugs designs.

Leave a comment

Your email address will not be published. Required fields are marked *