2

So I have a java web app on tomcat installed on the server. How can I setup auto start for it so that it starts up automatically when the server is restarted?

Daud Ahmad Khokhar
  • 121
  • 1
  • 1
  • 6

4 Answers4

1

/etc/init.d/tomcat-wepappname

#!/bin/sh 
### BEGIN INIT INFO 
# Provides:          tomcat-wepappname 
# Required-Start:    $all 
# Required-Stop:     
# Default-Start:     2 3 4 5 
# Default-Stop:      0 1 6 
# Short-Description: foo bar 
# Description:       long desc
### END INIT INFO 
# Author: Foo Bar <foo@bar.com> 

. /lib/lsb/init-functions 

# Actions 
case "$1" in 
 start) 
  log_action_begin_msg "Starting tomcat webapp" "tomcat-webappname"
  su - tomcat-webappuser -c "/home/sites/tomcat-webappname/webappname.sh $1" 
  log_end_msg 0 
  ;; 
 stop) 
  su - tomcat-webappuser -c "/home/sites/tomcat-webappname/webappname.sh $1" 
  ;; 
# restart) 
# something else...
#  ;; 
esac

exit 0

At least, register the service:

update-rc.d activemq defaults
Joe Nazz
  • 171
  • 1
  • 2
  • 9
0

One way to start the tomcat on the startup is to run it using cron using the @reboot attribute:

open up a terminal and type :

sudo crontab -e

at the end of the file enter the command:

@reboot /`PATH_TO_WHERE_TOMCAT_INSTALLED`/bin/startup.sh

save the file and exit.

The above command will run the command once everytime computer boots up.

Sobhan
  • 101
  • 2
0

Use

/sbin/chkconfig tomcat6 on

If you have installed the tomcat6 RPM.

Robert Munteanu
  • 1,644
  • 5
  • 23
  • 41
0

Found this article here that did it for me.

http://www.sitepoint.com/jsp-quick-start-guide-linux/

Daud Ahmad Khokhar
  • 121
  • 1
  • 1
  • 6