Re: psql remote shell command - Mailing list pgsql-general

From Stephen Frost
Subject Re: psql remote shell command
Date
Msg-id 20160602235450.GX21416@tamriel.snowman.net
Whole thread Raw
In response to psql remote shell command  (Dennis <dennisr@visi.com>)
Responses Re: psql remote shell command
List pgsql-general
* Dennis (dennisr@visi.com) wrote:
> Is it possible to execute command in on system the is hosting postgresql remotely using psql or other mechanism?  I
knowI can use \! in psql but that executes the commands on the host where I am running psql from.  Also, is it possible
fora 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

Attachment

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Slave claims requested WAL segment already removed - but it wasn't
Next
From: Stephen Frost
Date:
Subject: Re: psql remote shell command