I have a simple upstart script for tomcat. Here is the chef template:

description "Tomcat Server"

  start on runlevel [2345]
  stop on runlevel [!2345]
  respawn limit 10 5

  # run as non privileged user 
  # add user with this command:
  ## adduser --system --ingroup www-data --home /opt/apache-tomcat apache-tomcat
  setuid "<%= node['tomcat']['user'] %>"
  setgid "<%= node['tomcat']['group'] %>"

  # paths:
  env JAVA_HOME="<%= node["java"]["home"] %>"
  env CATALINA_BASE="<%= node["tomcat"]["base"] %>"
  env CATALINA_HOME="<%= node["tomcat"]["home"] %>/current"

  exec $CATALINA_HOME/bin/catalina.sh run

  # cleanup temp directory after stop
  post-stop script 
    rm -rf $CATALINA_HOME/temp/*
  end script

After switching from init script to the upstart script posted above, all tomcat logs are written to /var/log/upstart/tomcat. Is there any reason why all logs go into the upstart log? What's a good way to work around that? This is on ubuntu 12.04

1 Answer 1


The upstart cookbook provides an explanation for what's going on. In short, "Standard output and standard error are ... automatically logged to a file in directory /var/log/upstart/". The 'catalina.sh run' command sends all output to stdout. So, upstart is redirecting stdout to the upstart log.

I took the following approach to the problem:

# Manually specify CATALINA_OUT, so we can redirect ourselves
env CATALINA_OUT=<path to catalina_base>/logs/catalina.out

# Stop upstart from handling stdout/stderr & redirect to the log file ourselves
console none
exec $CATALINA_HOME/bin/catalina.sh run >> "$CATALINA_OUT" 2>&1

I tried to exec 'catalina.sh start', which if you look at the catalina script redirects output to CATALINA_OUT itself. But, I was unable to have upstart correctly manage the process. Neither 'expect fork' nor 'expect daemon' was able to manage the backgrounded process created from the catalina startup script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .