pir
pir

Reputation: 5933

Start Postgres DB if needed with pg_ctl

I know that I can start a Postgres DB using pg_ctl start -D $DBPATH, but that'll throw if the DB is already started. How do I start the DB only if it's not already running? Relatedly, how do I check if the DB is already running from only the file system?

Upvotes: 0

Views: 422

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 248125

For that, use

pg_ctl status -D $DBPATH

See the documentation for details.

Upvotes: 1

Related Questions