Linux – /etc/rc.local doesn’t execute apache tomcat startup script on boot

centoslinuxtomcat

I'm having some problem with my centOS machine.I want to insert a line inside the rc.local to execute apache tomcat on startup.
Below are the configuration for /etc/rc.local

#!/bin/sh 
# # This script will be executed *after* all the other init scripts. 
# You can put your own initialization stuff in here if you don't 
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/opt/apache-jakarta/bin/startup.sh

Unfortunately,the apache tomcat does not start on the boot time. I've already execute the script manually and it is working without any issues.
Is there any specific syntax to put script inside the rc.local?Or did I forgetting something?Please Advice.Thanks.

EDIT:

My boot.log only show this output:

Dec 17 21:04:53 localhost NET[2969]: /sbin/dhclient-script : updated /etc/resolv.conf

Best Answer

Add the below lines on the top of file "/usr/local/tomcat/bin/daemon.sh"

# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80

Then create a symlink

ll /etc/init.d/tomcat
lrwxrwxrwx. 1 root root 29 Oct 18 22:17 /etc/init.d/tomcat -> /usr/local/tomcat/bin/daemon.sh

Restart your server and your tomcat should be started. Try this method and see if this helps. Make sure you have enabled it in chkconfig

chkconfig --list | grep tomcat
tomcat          0:off   1:off   2:on    3:on    4:on    5:on    6:off