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'm trying to use upstart so that the pydoc webserver for a package I'm developing always runs. If I run it from the command line:

pydoc -p 7464 /some_path/my_python_package

it works fine, and going to localhost:7464/my_python_package displays the documentation. However if I put it in an upstart script, e.g.

start on startup
start on runlevel [2,3,4,5]
stop on runlevel [0,1,6]

    pydoc -p 7464 /some_path/my_python_package
end script

then when I open up the browser at localhost:7464/my_python_package I get the following:

no Python documentation found for 'my_python_package' 

Note that localhost:7464 shows all of the standard python packages as normal, so it seems like upstart isn't parsing the path correctly.

I tried using putting export PYTHONPATH='/some_path' in and changing the execution line to pydoc -p 7464 $PYTHONPATH/my_python_package but this didn't work either.

share|improve this question
up vote 2 down vote accepted

The syntax you've specified in that job is incorrect:

  • you have multiple 'start on' stanzas.
  • the last 'start on' stanza will be considered, but yours is invalid due to using commas between runlevels (your 'stop on' is invalid for the same reason).

You want something like this:

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

    pydoc -p 7464 /some_path/my_python_package
end script

Note that with version 0.9.7 and higher of Upstart (in other words Ubuntu Natty or newer - see, there is a new command called init-checkconf that will check your script for syntax errors. Usage is simple:

$ init-checkconf myjob.conf

Note that you must run init-checkconf as your user (not root).

Also, are you running this as a system job (job file lives in /etc/init/ ?) If so, do you really need the service to run as root? If not, see:

if this is a do you really need to run that service as the root user?

Finally, I would highly recommend taking a look at the rest of the Upstart Cookbook:

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.