79

I installed these applications on my Ubuntu:

  • nginx

  • php5-fpm

  • mysql server

  • redis

  • ...

These applications run every time the computer turns on.

How can I prevent these applications from running on start up?
So, these applications only run if I do "service nginx start".

Alexis Wilke
  • 2,707
Cakka
  • 891
  • for s in "nginx mysql redis"; do sudo update-rc.d $s disable; done – belteshazzar Jul 28 '16 at 07:20
  • Auto-start programs are configured in autostart manifests or in *.service files in several locations, as well as in init.d or crontab. See: https://unix.stackexchange.com/a/525845/43233 – Noam Manos Jun 20 '19 at 06:36

3 Answers3

167

Use:

systemctl disable <service>

If you are not using systemd (Ubuntu 14.10 and earlier) use:

update-rc.d -f <service> remove

The following command will give you a list of all services on your machine:

service --status-all

You should be able to find the names of the services you want to disable in there.

For more details, see enabling-and-disabling-services and for the very long answer see this post (as already mentioned by @muru).

For more details, see this post on Digital Ocean and the man page for systemctl.

qwertzguy
  • 663
NZD
  • 3,231
  • 1
    Starting with Ubuntu 15, this is no longer valid. systemctl disable SERVICE works (see the linked question in answer) – Ryre Apr 28 '17 at 03:27
  • The link in "For more details see ..." does not mention systemctl. I guess that was for old versions, but now it's confusing. – matteo Jun 23 '17 at 19:54
  • 3
    @matteo Up dated my answer with links to posts with more info on systemctl – NZD Jun 24 '17 at 04:57
-1

Another method is by installing rcconf apt-get install rcconf. From rcconf you can enable/disable any service that is installed on your ubuntu/debian server.

  • 4
    Except of course that it uses functionality of update-rc.d that was removed a few years ago (Debian bug #727735) and it doesn't work with systemd or upstart, i.e. either of the default init systems for Ubuntu Linux for the past decade. – JdeBP Nov 17 '15 at 09:14
-1

Install sysv-rc-conf

apt-get install sysv-rc-conf

Then simply to list services

sysv-rc-conf --list

To disable any services i.e nginx

sysv-rc-conf nginx off

For more information see man sysv-rc-conf

Juned
  • 101
  • 3
  • 7
    Except of course that it doesn't work with systemd or upstart. It is patently (it even being in the package name) only for the old System 5 rc system, which hasn't been the default on Ubuntu Linux for almost a decade. Debian Bug #791689 acknowledges this and questions why it hasn't been marked as conflicting with systemd. – JdeBP Nov 17 '15 at 09:26