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.

If I want to start a system installed service, I can do:

# /etc/init.d/some-svc start
# initctl start some-svc
# service some-svc start
# start some-svc

If I want to disable a service from running at boot, I can do:

# rm /etc/rc2.d/S99some-svc
# update-rc.d some-svc disable
# mv /etc/init/some-svc.conf /etc/init/some-svc.conf.disabled

Then there are similarly various things I can do to enable services for starting at boot, and so on.

I'm aware of the fact that upstart is a (relatively) new thing, and I know about how SysV init used to work, and I'm vaguely aware of a bunch of D-Bus nonsense, but what I don't know is how one is actually intended to interface with this stuff. For example, I don't know how to easily determine whether a service is an Upstart job or a legacy SysV thing, without actually reading through the source of its shell scripts extensively.

So: if I want to start or stop a service, either at the moment or persistently, which of these tools should I use, and why? If the answer depends on some attribute (like "this service supports upstart") then how do I quickly and easily learn about that attribute of an installed package?

Relatedly, are there any user interface tools which can safely and correctly interact with the modern service infrastructure (upstart, and/or whatever its sysv compatibility is)? For example, could I reliably use sysv-rc-conf to determine which services should start?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Functionally, there is no difference between any of these invocation methods.

start and stop are symbolic links to initctl. service is a shell script that determines whether to execute the init script or use initctl.

The simplest way to see what is an Upstart job is to take a look at /etc/init/. Everything in there is an Upstart job. If you ls -l /etc/init.d/ you'll see every service and system task. The SysV init jobs will be real files, while the Upstart jobs will be symlinks to /lib/init/upstart-job which will properly invoke the Upstart job.

In other words, you can also invoke Upstart jobs by calling, for example, /etc/init.d/apport restart, though the output will suggest using service, start, or stop instead.

So, in practice it makes no difference (yet!). But if I were scripting something, I would certainly use service, start, or stop as there is almost no chance that will deprecated, whereas calling services through /etc/init.d/ could go away down the road (though probably not any time soon).

A note on disabling services: renaming the .conf file works, but I don't recommend it. You might disable a service that way, but if there is a package upgrade available, dpkg will copy down a fresh copy of the Upstart job and without intending it, your service is enabled again. The correct way to disable an Upstart job is to use a .override file which leaves the original job intact.

For example, to disable apport, simply create a file called /etc/init/apport.override that contains the word "manual".

# echo "manual" > /etc/init/apport.override

Personally, I would avoid using sysv-rc-conf. It may be safe enough to use it to modify SysV jobs, but I'm not sure; it doesn't seem to support Upstart jobs, and there's no way to tell form the interface which is which. I would stick with update-rc.d for managing SysV scripts.

For more Upstart information see:

  1. The Upstart Cookbook: http://upstart.ubuntu.com/cookbook/
  2. The command man 5 init: http://manpages.ubuntu.com/manpages/precise/en/man5/init.5.html
share|improve this answer
    
So it sounds like it's best to stick with service because that will make the determination to go straight to the sysv init script if there's a reason to do that, and if I want to disable a service, I need to discover whether it's an upstart job or not? Can you include a reference to whatever documentation I should have found on my own, that would have lead me to that echo "manual" ... command? –  Glyph Oct 19 '12 at 16:46
    
The two best sources for Upstart information are The Upstart Cookbook (upstart.ubuntu.com/cookbook) and man 5 init (manpages.ubuntu.com/manpages/precise/en/man5/init.5.html) –  Mark Russell Oct 19 '12 at 16:54
    
And yep, your reading of the answer is right on. –  Mark Russell Oct 19 '12 at 17:00
    
The only thing you left out is marking my answer as correct. :-) –  Mark Russell Oct 19 '12 at 18:10
    
Just waiting for you to add those references! –  Glyph Oct 20 '12 at 17:48

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.