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)


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.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.