Red hat Linux: how to start tomcat server on boot?

Spydermag68

Platinum Member
Apr 5, 2002
2,615
98
91
I am trying to get a RH server to start tomcat every time I reboot the computer. I am able to update the .bash_profile file to do it when I log in but I need tomcat to restart when the server reboots.
 

ultimatebob

Lifer
Jul 1, 2001
25,134
2,450
126
Yeah, it would probably be something like

chkconfig tomcat8 on --level 35

making sure to substitute tomcat8 with whatever the real service name is.
 

mv2devnull

Golden Member
Apr 13, 2010
1,519
154
106
The chkconfig "on" and "off" commands update symlinks in runlevel-specifc subdirectories that init uses.
There is "chkconfig --add tomcat8" command to create the initial symlinks.
The chkconfig requires that the script file "/etc/init.d/tomcat8" contains configuration instructions as comments in format that chkconfig uses. Furthermore, the script should accept at least command line parameters "start" and "stop".

It is quite possible that a non-RPM-packaged program does not have a startup script that chkconfig can use. One could create such separate script for chkconfig that merely calls the actual startup script as appropriate.


However, it is not yet clear what the "RH Enterprise" is. There is RedHat Enterprise Linux (RHEL), but it has several major releases the latest being RHEL 7.

Up to RHEL 6 the service management did use chkconfig. RHEL 7 has replaced that with systemd and only a couple old services remain with only the chkconfig-style configuration and the chkconfig-command is a mere wrapper for systemctl. The systemd service configuration is entirely different.

There are a lot of strong opinions about systemd, even though several distros have adopted it recently.


Websearch suggests: http://tomcat.apache.org/tomcat-8.0-doc/setup.html#Unix_daemon

In other words, the contents of $CATALINA_HOME/bin/daemon.sh are interesting.
 

ultimatebob

Lifer
Jul 1, 2001
25,134
2,450
126
It sounds like the OP installed Tomcat "the hard way" and downloaded a binary from the Tomcat web site. It's a lot easier to download and use a prebuilt Tomcat .rpm file for RHEL on a place like rpmforge that likely includes the correct start scripts for init.d to work correctly.

If you're really lazy, I've even seen entire yum repos filled with preconfigured tomcat installations that you can use.
 

Jodell88

Diamond Member
Jan 29, 2007
8,762
30
91
If you're using systemd
Code:
systemctl enable tomcat8.service
The .service suffix is optional