LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

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


Hi,

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.

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

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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, 01:49 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
There is indeed a script in
Code:
~/src/postgresql-X.X.X/contrib/start-scripts
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.
 
  


Reply


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 04:03 AM
How to start X server automatically? sureshot324 Debian 5 08-20-2007 04:52 PM
Start a server automatically? timmyk0 Linux - General 8 06-24-2006 03:58 AM
Can't get apache server to automatically start on boot bowie101 Linux - Newbie 11 05-03-2006 12:07 PM
how to start automatically apache server when boot-up? eye Linux - Software 7 10-28-2003 02:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:47 AM.

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