Re: Execute commands in single-user mode - Mailing list pgsql-general

From Andreas Joseph Krogh
Subject Re: Execute commands in single-user mode
Date
Msg-id VisenaEmail.53.1bc2be95bd1a144d.1522c08b064@tc7-visena
Whole thread Raw
In response to Re: Execute commands in single-user mode  (Melvin Davidson <melvin6925@gmail.com>)
Responses Re: Execute commands in single-user mode
List pgsql-general
På søndag 10. januar 2016 kl. 15:52:12, skrev Melvin Davidson <melvin6925@gmail.com>:
Well, you can't combine psql with the postgres startup, but you can issue subsequent commands from bash with the -c option:
 
EG:

postgres --single -O -D $PGDATA $DB_NAME
# give postgres a few seconds to complete startup
sleep 30
psql -U postgres -d your_database -c "alter table pg_largeobject set tablespace some_tablespace;"
 
pg_ctl stop -d $PGDATA -m fast
 
How can that work?
 
Starting in single-mode gives you a prompt, so there's no way to issue another command. Even if it was, PG is not accepting connections, so using psql won't work, unless I'm misstaken...
 
BTW, it's always good form to state the exact O/S and version of PostgreSQL, regardless of whether you think it may apply.
 
Yea, sorry, it's 9.5.0
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
 
Attachment

pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: Execute commands in single-user mode
Next
From: Melvin Davidson
Date:
Subject: Re: Execute commands in single-user mode