How do you nicely stop all postgres processes with pg_ctl
(or otherwise), when you don't recall what the database directory is, nor have the PGDATA environment variable defined?
Ubuntu – how to nicely stop all postgres processes
postgresql
postgresql
How do you nicely stop all postgres processes with pg_ctl
(or otherwise), when you don't recall what the database directory is, nor have the PGDATA environment variable defined?
Best Answer
It's safe to:
That kills all processes running as user
postgres
. Or:That kills all processes named 'postgres'.
Do not use
kill -9
(kill -KILL
). Justkill
(without options) does aSIGTERM
, which is what you want.Alternatively, you can check the pgdata location if you can connect to PostgreSQL. For example:
...or by checking its environment variables in
/proc/[postmaster pid]/environ
, where you identify the postmaster withps -fHC postgres
. Look for the one that's the parent of the otherpostgres
processes. For example:Its datadir will generally be shown on its command line.