Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I have an upstart script like so:

start on runlevel [2345]
respawn

script
  exec su - ubuntu -c "cd /opt/app; bin/widget 2>&1 | logger -t 'widget'"
end script

The problem is when the widget process crashes, it doesn't respawn. Presumably because the logger process is still running. Any way around this?

share|improve this question
up vote 1 down vote accepted

I would "outsource" the work to a bash script:

start on runlevel [2345]
respawn

script
  exec /path/to/bash/script
end script

the script

#! /bin/bash -e

su - ubuntu -c "cd /opt/app; bin/widget" |& logger -t 'widget'

exit ${PIPESTATUS[0]}

The PIPESTATUS array in bash stores pipe return values, in this case we use the return value of the su command.

share|improve this answer

Your Answer

 
discard

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.