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 written several upstart scripts to start transmission-daemon for several users. The script is this:

start on (local-filesystems and net-device-up IFACE=eth0 and runlevel [235])
stop on runlevel [016]

kill timeout 50


env USER=user
env PIDFILE=/var/run/

    DAEMON=$(which transmission-daemon) || exit 0

    exec start-stop-daemon --start --quiet --chuid $USER --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- -f --config-dir $CONFIGDIR --logfile $CONFIGDIR/daemon.log
end script

post-stop exec rm -f $PIDFILE

I would convert this:

env USER=user
env PIDFILE=/var/run/

To this:

env USER=user
env PIDFILE=/var/run/transmission-$

But upstart doesn't allow. I can do it if I move those lines to the script section:

end script

But in this case, the PIDFILE, in post-stop section, is empty.
Is there any way to do this?

share|improve this question

This is a fairly old bug in upstart:

To get the variable in post-stop and script... you'll just have to set it both times to work around the bug.

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.