To make Tomcat automatically start when system boots, you can add Tomcat as a service with the following steps (Assume you have Linux machine):
Step 1: add a script using command "sudo vi /etc/init.d/tomcat"
paste the following content into the file:
# Tomcat auto-start
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
export JAVA_HOME=/usr/lib/jvm/java-6-sun
case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac
exit 0
In this example, we assume the java path is /usr/lib/jvm/java-6-sun and tomcat path is /usr/local/tomcat.
Step 2: make the script executable by running the chmod command:
sudo chmod 755 /etc/init.d/tomcat
Step 3: link this script to the startup folders by running the following commands
sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc3.d/K04tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc3.d/S98tomcat
chkconfig --level 2345 tomcat on
Now, Tomcat has been set as auto-starting for system restart.
No comments:
Post a Comment