Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wrote a simple upstart script that kicks off a python program, I have it saved as vgpusher.conf.

It doesn't start automatically, but if I run sudo start vgpusher it starts and runs just fine.

The code is simple:

description "vgpush"

start on runlevel [2345]
stop on runlevel [!2345]

script
    cd /home/computer/
    python pusher.py
end script

I placed the script in /etc/init. Other than that, I have done no configuration.

The machine is running Ubuntu 10.04 Server.

Do I need to take an extra step for the service to start on startup?

share|improve this question
2  
Please explain in more detail how you have configured your script as a service: where did you put vgpusher.conf, what is the contents of this file, where did you set the runlevel etc. –  January Jul 8 '13 at 14:34
    
@January Added more information, thanks –  mitchfish36 Jul 8 '13 at 14:42

2 Answers 2

up vote 2 down vote accepted

First, you don't need script:

description "vgpush"

start on runlevel [2345]
stop on runlevel [!2345]

chdir /home/computer
exec python pusher.py

Second, it may help to log the output. If you upgrade to 12.04 (Highly recommended!) you will have a log in /var/log/upstart/$jobname.log. For 10.04, you have to do it manually:

description "vgpush"

start on runlevel [2345]
stop on runlevel [!2345]

chdir /home/computer
exec python pusher.py 2>&1 >> /var/log/vgpush.log

That may give some clue. If I had to guess, it is because vgpush needs a network interface to be up that is not, and 10.04 starts runlevel 2 before all network interfaces are ready.

share|improve this answer

When troubleshooting an upstart job, there are a few things to check.

  1. Check the upstart job is correct. Yours looks pretty good, but I would suggest using the full path to the python executable ( /usr/bin/python ).

  2. Check the upstart job log. there is a log file for each job at /var/log/upstart/.log It's possible that your job is starting and failing for some reason (maybe pusher.py needs the network to be up) and this log file will probably have information on that. At the least, it will at least show if the job is trying to start.

share|improve this answer
    
Using an explicit python path is not necessary. PATH will be set to the system default and the system python will always be in the default system path. –  SpamapS Jul 8 '13 at 17:10

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.