Ubuntu – Upstart, one job definition to start and one to stop

scriptsupstart

Hi i just discoverd ubuntu upstart (etc/init/* scripts).
And i would like to use it to run a particular application.
This app is run via a command line, but there is an argument to start an instance of the app and another argument to stop it (let say 'start' and 'stop')
Is there a way to use upstart for that ??

Best Answer

It should be as simple as creating a file /etc/init/myjob.conf:

description    "My Job"

# start conditions for automatic start
# stop conditions for automatic stop

pre-start exec /path/to/program start
post-stop exec /path/to/program stop

You should then be able to do sudo start myjob to start and sudo stop myjob to stop.

See http://upstart.ubuntu.com for some more info.

Related Question