Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-05-2010, 12:07 AM   #1
LQ Newbie
Registered: Aug 2008
Posts: 9

Rep: Reputation: 0
how do I start postgresql server automatically when boot?


I followed the INSTALL file to compile/build and postgresql. It also tells you to start the server by issuing the following commands

su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &

I'm wondering how I start it automatically when I boot up the ubuntu 10.04? especially, when I created the user "postgres", I set a password to it. every time I issued "su - postgres" command, I need to give it a password.

thanks for any advise.

Old 08-05-2010, 12:27 AM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977
Is there a reason you built it yourself? You should normally just run "sudo aptitude install postgresql" and it'll be installed for you completely, including the additional scripts to start on boot. This should be your principle concern, installing this way instead.

From source though there may well be a startup script in the source directories to do all this, but you can just run these commands directly if need be. you wouldn't need to enter a password if these are added to /etc/rc.local as it'd run as root, not as your normal user account. but you can't run these commands in a script though, as when you run the su command it will fork into a new shell.

if you ran "su - postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &" then that should start it and continue on, but again you should really use a proper service script, especially for a service as large as a database.
Old 08-05-2010, 12:49 AM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
There is indeed a script in
that one would have to adjust to match the locations
chosen, and to make it match ubuntus init.

That said: with Ubunut you really shouldn't have to
compile from source.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Start postgresql server on OpenSuSE 10.3 billmasters Linux - Software 11 02-20-2008 03:03 AM
How to start X server automatically? sureshot324 Debian 5 08-20-2007 03:52 PM
Start a server automatically? timmyk0 Linux - General 8 06-24-2006 02:58 AM
Can't get apache server to automatically start on boot bowie101 Linux - Newbie 11 05-03-2006 11:07 AM
how to start automatically apache server when boot-up? eye Linux - Software 7 10-28-2003 01:22 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:37 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration