27

I have postgresql 8.4 installed on my desktop. It keeps starting on bootup because I think I used default settings.

so I issue /etc/init.d/postgresql stop everytime and sometimes i keep forgetting

It has folder paths as,

/etc/postgresql/8.4/main
/usr/lib/postgresql/8.4

There are a lot of configuration files and if someone can tell me where to look and what to change, that will be great.

Thanks.

5 Answers 5

46

On Ubuntu 16.04 or later (which use systemd) you'd use this command

sudo systemctl disable postgresql

If you want to re-enable, you'd do

sudo systemctl enable postgresql

On Ubuntu 15.10 and older, you can use update-rc.d:

janus@Zeus:~$ sudo update-rc.d -f postgresql remove
 Removing any system startup links for /etc/init.d/postgresql ...
   /etc/rc0.d/K21postgresql
   /etc/rc1.d/K21postgresql
   /etc/rc2.d/S19postgresql
   /etc/rc3.d/S19postgresql
   /etc/rc4.d/S19postgresql
   /etc/rc5.d/S19postgresql
   /etc/rc6.d/K21postgresql
janus@Zeus:~$
2
  • 2
    this is the proper way to do what was requested
    – glarrain
    Nov 11, 2013 at 14:55
  • And if you want to do both stop and disable, you can simply do sudo systemctl disable --now postgresql. See man systemctl for details. Similarly you can add --now flag to the command enable, too. Mar 22, 2023 at 13:44
7

Using update-rc.d is better but you can do it with chkconfig:

sudo apt-get install chkconfig
sudo chkconfig -s  postgresql off

In Ubuntu 12.04, you also need to create a symlink to insserv's location:

sudo ln -s /usr/lib/insserv/insserv /sbin/insserv
1
  • I had to create the symlink using 10.10 as well. In addition I got this large output as a response: pastebin.com/fPKRj5Gr
    – deprecated
    Dec 27, 2012 at 20:52
6

This can help you: http://www.linuxquestions.org/questions/linux-general-1/how-to-remove-postgresql-from-startup-481963/#post2417585

But install chkconfig first:

sudo apt-get install chkconfig

and then use it

chkconfig
3
5

The answers in here are outdated. Take a look at Daniel Vérité's answer on Preventing PostgreSQL from starting on boot in Ubuntu - Database Administrators Stack Exchange.

Ubuntu or Debian can run multiple instances of PostgreSQL and provide a specific way to autostart/stop/start each cluster.

There should be a file named start.conf inside /etc/postgresql/9.2/main (or more generally /etc/postgresql/<version>/<clustername>) with these self-explanatory contents:

# Automatic startup configuration
# auto: automatically start/stop the cluster in the init script
# manual: do not start/stop in init scripts, but allow manual startup with
#         pg_ctlcluster
# disabled: do not allow manual startup with pg_ctlcluster (this can be easily
#           circumvented and is only meant to be a small protection for
#           accidents).

auto 

If you replace auto by manual, you could start this PostgreSQL instance only when desired with the command:

sudo pg_ctlcluster 9.2 main start

As for looking at the console, what you should want instead is having this run in a terminal when you work with the database:

tail -f /var/log/postgresql/postgresql-9.2-main.log
1
  • Please don't post link-only answers to other Stack Exchange questions. Instead, include the essential portions of the answer here, and tailor the answer to this specific question. Jun 11, 2019 at 15:39
-1

On my server there is another effect:

# update-rc.d -f postgresql remove
update-rc.d: using dependency based boot sequencing

No system startup links were removed.

You must log in to answer this question.

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