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.

1 Answer 1


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.

You must log in to answer this question.

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