I installed postgresql in a jail, it starts automatically after adding postgresql_enable="YES" to /etc/rc.conf), but now I can't stop it.

I tried /usr/local/etc/rc.d/postgresql stop, but I've got:

pg_ctl: PID file "/usr/local/pgsql/data/postmaster.pid" does not exist
Is server running?

But of course it is runnging, I can connect to it using psql, also when I do ps ax|grep postgres I get:

15411  -  SsJ  0:00.07 postgres: logger process    (postgres)
15412  -  SsJ  0:00.05 postgres: startup process    (postgres)
15413  -  SsJ  0:00.01 postgres: checkpointer process    (postgres)
15414  -  SsJ  0:00.02 postgres: writer process    (postgres)
15415  -  SsJ  0:00.00 postgres: stats collector process    (postgres)
15410  2  SJ   0:00.17 /usr/local/bin/postgres -D /usr/local/pgsql/data

I need to gracefully stop it from a script, how can I do this?.


I think the init scripts are confused because my data_directory is different the default ConfigDir, in fact, the PID file is created in my data_directory which points to /mnt/postgresql.

1 Answer 1


I fixed it by adding postgresql_data="/mnt/postgresql" to /etc/rc.conf and leaving the data_directory field as default (commented and pointing to 'ConfigDir':

#data_directory = 'ConfigDir'

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.