Start postgresql server when booting Linux system

I want the postgresql server on my Linux machine to start automatically when the system boots. I added the following line to the ~ / .profile file:

su -c 'pg_ctl start -D /var/lib/pgsql/data ' postgres 

however, the postgres server does not start until I get a console command. Then I will be asked to enter the password "postgres" of the user, and then the server will start correctly.

I want to avoid two additional steps related to the linux console and entering the password for the postgres user. How can i do this?

+4
source share
2 answers

Here is an excerpt from manual 8.0, which shows how to do this with 8. * and for different distributions:

http://www.postgresql.org/docs/8.0/static/postmaster-start.html

and here for the latest released version: http://www.postgresql.org/docs/9.1/static/server-start.html

On Linux systems, add /usr/local/pgsql/bin/pg_ctl start -l logfile -D /usr/local/pgsql/data
before /etc/rc.d/rc.local or /etc/rc.local
or view file
contrib/start-scripts/linux in the original PostgreSQL distribution.

Check the item starting with "Different systems have different conventions for running daemons at boot time."

Hope this helps. Edmon

+3
source

Usually you do this with your initialization system. In traditional unixes, this means /etc/init.d scripts, but on modern ones, including major Linux distributions, often something else.

Having said that on modern Unix systems, installing PostgreSQL using the package manager usually causes it to start at startup, so you don’t even have to.

What Linux distribution do you use, and how did you install PostgreSQL?

+1
source

All Articles