From: | Stephen Frost <sfrost(at)snowman(dot)net> |
---|---|
To: | Dennis <dennisr(at)visi(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: psql remote shell command |
Date: | 2016-06-02 23:54:50 |
Message-ID: | 20160602235450.GX21416@tamriel.snowman.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
* Dennis (dennisr(at)visi(dot)com) wrote:
> Is it possible to execute command in on system the is hosting postgresql remotely using psql or other mechanism? I know I can use \! in psql but that executes the commands on the host where I am running psql from. Also, is it possible for a postgres login/user to stop or restart a running postgres instance from in side psql or similar client. e.g. psql -c “pg_ctl stop -D some_data_dir”
You can use COPY with PROGRAM, assuming you're a superuser.
COPY (select 1) TO PROGRAM 'whatever command';
You could use that to issue a pg_ctl stop, though you'll then lose your
connection to the database.
You can 'reload' the running configuration by using:
select pg_reload_conf();
Not all parameters can be changed while PG is running, but most of them
can be. Parameters in postgresql.conf can be updated via ALTER SYSTEM
through psql also.
Issuing a 'pg_ctl restart' via COPY PROGRAM isn't a good idea and may
not work, though I suppose you could try if you really wish to.
Thanks!
Stephen
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2016-06-02 23:55:05 | Re: Slave claims requested WAL segment already removed - but it wasn't |
Previous Message | Michael Paquier | 2016-06-02 23:54:07 | Re: psql remote shell command |