59

Ubuntu 16.04.1 LTS I have tried:

sudo update-rc.d -f postgresql remove

and

sudo vim /etc/postgresql/9.5/main/start.conf

then i change the word "auto" to "disabled"

Then i reboot the computer, and when it starts, i login and do:

sudo service --status-all | grep postgresql

Which returns:

[ + ]  postgresql

So it is still starting when the server starts. What is left for me to do? I don't want this service running when the computer starts, only when i manually start it with:

sudo service postgresql start
asdf
  • 899
  • 1
  • 6
  • 10
  • 1
    See the SystemD section here: https://askubuntu.com/questions/19320/how-to-enable-or-disable-services – Koen De Groote Jan 08 '17 at 01:40
  • Thank you. I don't know which solution fixed it, but it's fixed now. It won't let me mark a best answer. – asdf Jan 08 '17 at 01:59
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. Also see [Where do I post questions about Dev Ops?](http://meta.stackexchange.com/q/134306) – jww Jan 08 '17 at 20:08

2 Answers2

157

Use systemctl command to manage postgresql service:

  1. stop service:

    systemctl stop postgresql

  2. start service:

    systemctl start postgresql

  3. show status of service:

    systemctl status postgresql

  4. disable service(not auto-start any more)

    systemctl disable postgresql

  5. enable service postgresql(auto-start)

    systemctl enable postgresql

g10guang
  • 4,647
  • 3
  • 28
  • 22
  • 4
    The service still auto-starts after a `sudo systemctl disable postgresql@10-main`. `sudo service postgresql@10-main disable` doesn't work, either. Perhaps editing `/etc/postgresql/10/main/start.conf` might do the trick. – Sussch Sep 04 '20 at 13:52
  • I tried disabling it.. but I'm getting a permission denied error.. @g10guang - need to add sudo! – Akhila Aug 16 '21 at 09:49
  • It really helped me out. It works perfectly. – 山の平和 Sep 03 '22 at 09:32
  • 1
    on ubuntu 20.04.5 i needed to edit /etc/postgresql/[VERSION]/main/start.conf and change auto -> disabled – Derek Adair Mar 12 '23 at 11:37
14

Ok. it's fixed thanks to Koen De Groote.

I did:

echo manual | sudo tee /etc/init/postgresql.override

and

sudo systemctl disable postgresql.service

and

sudo systemctl disable postgresql

....I don't know which one of them did it, but its not starting any more... Thank you...

asdf
  • 899
  • 1
  • 6
  • 10