Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What might be the best way to start up tomcat instances automatically? I have numerous vhost configured to use tomcat on various ports. I am sure someone out there came across this challenging admin task. Do you think rc.local will do? I dont want to cloud that file with so many commands, I want a once off script if its applicable.

share|improve this question
up vote 2 down vote accepted

The best way under linux is with a standard SysV Init script. That is the way daemons are supposed to be started under linux so that is the first place most sys admins will look.

Standards are good like that. ;)

Many distros ship with a skeleton startup script which you can modify to suit and some ship with a library of shell functions which you can source to help you write a startup script e.g. on redhat there's /etc/init.d/functions.

You might just use it to call the standard startup script that comes with Tomcat. Tomcat may even come with a SysV init script, I can't recall, it's been ages since I installed vanilla tomcat.

Make your startup script chkconfig-able too!

share|improve this answer
Yes there is a tomcat SysV init script, well this one is starting some instances but not all. Some tomcat instances are sitting in different dir, where tomcat init script in not pointing at. I can't say whay this was done,I inherited the servers. Some info that I might have left out; there is also a tomcat instance that was installed from source and some vhosts are pointing to that one. I reckon that rc.local will be an easy way out while I do sane :) – Rungano Jun 23 '09 at 6:09
Then copy the existing tomcat startup script and edit it to point at the other instances. Or create new tomcat startup scripts and put the commands you were going to put into rc.local in them. Init scripts are the right way to go and you don't lose anything by using them. It makes it easier for the next guy who takes a look at the box. – Jason Tan Jun 23 '09 at 15:16

I usually use Condor for managing my 'jobs' - it allows you to distribute your app dynamically or statically if you wish. Then you should be able to use whatever auto-start mechanism you like without having your configuration floating around for everyone to see.

share|improve this answer

Why not run them all inside the same tomcat instance? Tomcat can listen on multiple ports and serve different sets of webapps from different webapp directories. Investigate the <engine> element in the tomcat's server.xml documentation.

share|improve this answer

I would recommend something like daemontools or monit. SysV or Debian initscripts are fine for starting the process on boot, but they don't automatically restart your instance if it should stop.

For daemontools you'll need to create a run script that sets the user and the correct environment variables then runs $TOMCAT/bin/ run.

For monit you'll need to know the location of the tomcat pid file then use a configuration similar to this:

check process 'tomcat' with pidfile /path/to/your/tomcat/tmp/
   start command = '$TOMCAT/bin/ start'
   stop  command = '$TOMCAT/bin/ stop'
share|improve this answer
I have nagios to monitor the web pages so I will be notified via sms that a certain web page is not loading properly. Thank you big time for broading my options. :) – Rungano Jun 24 '09 at 6:43

I wrote a custom init script which assumes a directory /var/tomcat contains subdirectories, each of which is the configuration for a Tomcat instance. It iterates over each subdirectory, checks whether conf/server.xml exists, and if so sets CATALINA_BASE to that subdirectory and runs its bin/ script with the appropriate argument (stop|start).

share|improve this answer
Can you paste that script here? – Rungano Aug 7 '09 at 14:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.