Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to run my second postgresql instance when linux boots. I added this command (like in postgresql documentation) in rc.local:

/usr/lib/postgresql/9.1/bin/pg_ctl start -l logfile -D /var/lib/postgresql/9.1/main2

But if I try to run pg_ctl:

cannot be run as root

Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
t, it gives me this error:

How can I specify to run that command as postgres, but actually execute it with root (because root owns it).

Or is there some better way to make second init script for postgresql?

P.S. (I'm using Ubuntu)

share|improve this question
    
Copied and pasted from stackoverflow.com/q/24078385/398670 . –  Craig Ringer Jun 6 at 9:28
add comment

1 Answer 1

up vote 0 down vote accepted

If you're on Ubuntu, which it seems like you are, you don't have to roll any of this yourself.

Read the docs for pg_ctlcluster, pg_createcluster, pg_lsclusters. These are part of the pg_wrapper package for Ubuntu, which provides management of multiple instances and versions built-in.

share|improve this answer
    
Thanks. This was very useful –  Andrius Jun 6 at 11:13
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.