Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am using PostgreSQL 9.2 and it runs automatically when I start the system (Kubuntu).

How can I avoid this?

I need to start it manually, and I don't want it to start unattended because I need to look at the console.

share|improve this question
    
PostgreSQL is set up to log to /var/log/postgresql automatically on Ubuntu systems. Look there. You don't need to run Pg in a terminal to get its logging output. –  Craig Ringer Dec 31 '12 at 5:06
    
Thank you for this information, it is very useful. –  DarkCoffee Dec 31 '12 at 6:22
add comment

2 Answers

up vote 6 down vote accepted

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
share|improve this answer
    
Thank you so much! –  DarkCoffee Dec 31 '12 at 15:01
add comment

Short Term

The command /usr/sbin/update-rc.d is used to start, stop, enable, or disable services.

Type "man update-rc.d" to familiarize yourself with the command and its parameters.

Then type something along the lines of "sudo update-rc.d disable [service]" for any service listed in your /etc/init.d/ directory. That will prevent [service] from starting at boot. If you also want to shut down the service immediately, try "sudo update-rc.d stop [service]"

Long Term

you probably do not need to run postgresql manually in order to see its console output. You just need to log that output, and tail the log file.

share|improve this answer
    
Thank you for your answer. When I run $ sudo update-rc.d disable postgres returns update-rc.d: /etc/init.d/disable: file does not exist `, the same also for stop. –  DarkCoffee Dec 31 '12 at 6:25
    
Sorry, my bad. I transposed words while typing my comment. Here are some examples from the update-rc.d man page: update-rc.d -f foobar remove update-rc.d foobar stop 20 2 3 4 5 . –  mikemcc Dec 31 '12 at 16:19
    
Thank you for helping me. –  DarkCoffee Dec 31 '12 at 22:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.