Auto-start PostgreSQL in Linux

Posted by {"name"=>"Palash Ray", "email"=>"paawak@gmail.com", "url"=>"https://www.linkedin.com/in/palash-ray/"} on July 10, 2008 · 1 min read

This post is outdated. Please see this instead:
http://palashray.com/fedora-getting-up-and-running-with-postgres-in-2-mins/
I had faced lot of problems starting Postgres when my system boots-up. The challenge is that the postmaster daemon should be started by the under-privileged user "postgres" and NOT "root". This is what you must do:

In the source distribution of postgres, there is a file called linux in contrib/start-scripts/. Open this file and follow the instructions.
I will enumerate them as commands. Please note that you have to run these as root.
cp POSTGRES_SRC_DIST/contrib/start-scripts/linux /etc/rc.d/init.d/postgresql
ln -s /etc/rc.d/init.d/postgresql /etc/rc.d/rc0.d/K02postgresql
ln -s /etc/rc.d/init.d/postgresql /etc/rc.d/rc1.d/K02postgresql
ln -s /etc/rc.d/init.d/postgresql /etc/rc.d/rc2.d/K02postgresql
ln -s /etc/rc.d/init.d/postgresql /etc/rc.d/rc3.d/S98postgresql
ln -s /etc/rc.d/init.d/postgresql /etc/rc.d/rc4.d/S98postgresql
ln -s /etc/rc.d/init.d/postgresql /etc/rc.d/rc5.d/S98postgresql

You might also want to read these:

  • http://www.postgresql.org/docs/7.4/static/postmaster-start.html
  • http://www.postgresql.org/docs/8.3/static/server-start.html