Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

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/ 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

share|improve this question
up vote 2 down vote accepted

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 ' 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/ run >> "$CATALINA_OUT" 2>&1

I tried to exec ' 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.

share|improve this answer

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.