31

I've installed mongodb v3.4. This starts up on boot.

So I'm wondering, how to I find out what is starting this up (and how to disable it from starting on boot)?

The following did not work:

How can I stop mongodb from starting on system boot (old)

Command to list services that start on startup? (old)

1
  • 3
    service --status-all list all the services. You can refer this
    – Vishnu N K
    May 5, 2017 at 14:48

3 Answers 3

61

As far as I now, services are automatically enabled in Ubuntu, so when you install something like Apache it will be started at boot.

Find some information

To find out all services that have been run at startup:

systemctl list-units --type service

this will show all services that has been loaded at boot and are active now. If you want to get a list of all services no matter they are active or not:

systemctl list-units --type service --all

Another thing you can do is to run:

systemctl list-dependencies --type service

then hit / and search for mongodb see what service/target depends on it and runs it.

Also you can run :

locate mongodb.service

Which produces something like:

/lib/systemd/system/multi-user.target.wants/mongodb.service

then you will know that it's being started as a part of multi-user target, alternative to this is:

$ systemctl cat mongodb.service | grep -i wantedby
WantedBy=multi-user.target

Disable it

To find out that if it's active (Will be run at startup/boot-time):

systemctl is-active mongodb

It's either active or inactive; In your case it should be active.

To stop it from being started at boot time we should disable it:

sudo systemctl disable mongodb

And to make sure nothing else (No other service) can start it, we mask it:

systemctl mask mongodb

so it will be linked to /dev/null and can't be started automatically or manually anymore.

I'm not aware of mongodb service name, try hitting the tab it will be completed. I guess it's mongodb ;)

2
  • systemctl list-units --type service will not show users services. Wondering is there a way to show all = system and all users services ?
    – EdiD
    Dec 20, 2018 at 16:22
  • sudo update-rc.d mongodb disable
    – CRTLBREAK
    Oct 8, 2019 at 5:01
14

To know if a service is enabled at boot time, the right command is :

systemctl is-enabled apache2
enabled

You can try by yourself by changing the state with

systemctl enable apache2
systemctl disable apache2

(this isn't intended to be the answer)

1

Also have a look at Settings -> Session and Startup -> Application Autostart to see if your application is mentioned there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .