Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I'm just getting into upstart so i wrote a very basic script just to print to log file called: vm-service.conf that I put in /etc/init:

description "Virtual Images"
author      "Me"

start on runlevel [2345]
stop on runlevel [016]

echo "DEBUG: `set`" >> /tmp/vm-service.log

end script

pre-stop script
    echo "DEBUG: `set`" >> /tmp/vm-service.log
end script

if I run sudo start vm-service, it outputs:

vm-service start/running, process 29034

But, when I run sudo stop vm-service, it outputs:

stop: Unknown instance

I've tried running sudo initctl reload-configuration, but i still get the error on stop.

I've looked at the cookbook but I'm probably missing something obvious.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Upstart will consider the job stopped if the main process (what is run if the script or exec stanzas are specified) exits. Upstart will then run the post-start process.

So what is happening is the first script is running and exiting, Upstart is considering the job stopped, then the second script is running and exiting. If you run the stop command on an already stopped job, it prints the message you saw.

To handle this, use a pre-start stanza:

pre-start exec foo --bar

post-start exec baz --foo

if you do this, Upstart will see the job as started once the pre-start stanza finishes, and not as stopped.

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.