8

How do I stop an init.d server from running on boot, but still allow running it manually?

Matthew Flaschen
  • 868
  • 2
  • 7
  • 11

2 Answers2

11

See the man page for update-rc.d.

To stop a service from running at boot:

update-rc.d -f servicename remove

Or:

update-rc.d servicename stop 20 2 3 4 5 .

If you have Debian squeeze or later, or Ubuntu 12.10 or later:

update-rc.d servicename disable

To allow a service to run at boot:

update-rc.d servicename defaults

If you have Debian squeeze or later, or Ubuntu 12.10 or later:

update-rc.d servicename enable

To run the service manually:

service servicename start
service servicename restart

To stop the service manually:

service servicename stop
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • 1
    According to the manpage, `-f servicename remove` is technically only supposed to be used when you're removing the associated initscript entirely; `disable` is more correct. – tgies Jan 04 '13 at 02:14
  • 1
    @tgies The `disable` option may not exist on the target system. It appears to have been introduced in squeeze, and doesn't exist on Ubuntu systems at all. – Michael Hampton Jan 04 '13 at 02:17
  • It definitely exists on at least Ubuntu 12.10; I actually had occasion to use it yesterday. sysv-rc version 2.88dsf-13.10ubuntu13. But I didn't know it was a recently-added thing, so thank you. – tgies Jan 04 '13 at 02:27
  • @MichaelHampton as a note, all versions of Debian older than Squeeze have reached end of life. Lenny is no longer covered by the security team. – Matthew Flaschen Jan 04 '13 at 20:08
  • @MatthewFlaschen I've incorporated those into my answer. Keep in mind that we like answers that will be useful not only today, but hopefully years from now. :) – Michael Hampton Jan 04 '13 at 20:15
  • @MichaelHampton, at the same time, if you're still using Lenny or older you're risking unpatched vulnerabilities. – Matthew Flaschen Jan 04 '13 at 20:16
  • @MatthewFlaschen You'd be surprised what sorts of antiques are lurking in dark data centers and server closets... but that's neither here nor there. – Michael Hampton Jan 04 '13 at 20:17
2

On Debian Squeeze and up:

sudo update-rc.d server-name disable

To reverse:

sudo update-rc.d server-name enable
Matthew Flaschen
  • 868
  • 2
  • 7
  • 11