I have a script that I would like to run as a service on my Ubuntu Server 11.04 headless box. That is, I want to have the correct files under /etc/init.d/ and to be able to control it via the service command.

Is there any guide available that will show me how to do this?

link|improve this question

feedback

2 Answers

up vote 6 down vote accepted

You will probably be better off if you turn your script into an Upstart job, rather than follow the examples you'll find in /etc/init.d/ (which are System V-style init scripts, which Ubuntu and other distributions are moving away from).

The Upstart Cookbook has an enormous amount of information about how Upstart jobs work. Although I wouldn't describe it as a HOWTO, if you combine the information there with looking through the stock Ubuntu Upstart jobs in /etc/init/ you will start to get the picture.

I suggest starting with section 4 and 5 of the Cookbook, "Concepts and Terminology" and "Configuration"

link|improve this answer
feedback

Here is a very simple example how to create an upstart script: https://wiki.frugalware.org/index.php/Upstart_Job_HOWTO

You should place the script in /etc/init/yourfilename.conf

Then reload the configuration with:

sudo initctl reload-configuration

And if all is OK, you should be able to start it with:

sudo start yourfilename
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.