2000-04-08 04:16:26 +02:00
|
|
|
<!--
|
2010-09-20 22:08:53 +02:00
|
|
|
doc/src/sgml/ref/pg_ctl-ref.sgml
|
2001-12-08 04:24:40 +01:00
|
|
|
PostgreSQL documentation
|
2000-04-08 04:16:26 +02:00
|
|
|
-->
|
|
|
|
|
2000-10-08 15:22:24 +02:00
|
|
|
<refentry id="app-pg-ctl">
|
2014-02-24 03:25:35 +01:00
|
|
|
<indexterm zone="app-pg-ctl">
|
|
|
|
<primary>pg_ctl</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
2000-04-08 04:16:26 +02:00
|
|
|
<refmeta>
|
2010-04-03 09:23:02 +02:00
|
|
|
<refentrytitle><application>pg_ctl</application></refentrytitle>
|
2000-11-25 18:17:30 +01:00
|
|
|
<manvolnum>1</manvolnum>
|
2000-04-08 04:16:26 +02:00
|
|
|
<refmiscinfo>Application</refmiscinfo>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
2000-11-25 18:17:30 +01:00
|
|
|
<refname>pg_ctl</refname>
|
2011-06-08 19:51:25 +02:00
|
|
|
<refpurpose>initialize, start, stop, or control a <productname>PostgreSQL</productname> server</refpurpose>
|
2000-04-08 04:16:26 +02:00
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
2000-11-25 18:17:30 +01:00
|
|
|
<cmdsynopsis>
|
2009-12-10 07:32:28 +01:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>init[db]</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-s</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-o</option> <replaceable>initdb-options</replaceable></arg>
|
2010-09-25 08:57:09 +02:00
|
|
|
</cmdsynopsis>
|
2009-12-10 07:32:28 +01:00
|
|
|
|
2010-09-25 08:57:09 +02:00
|
|
|
<cmdsynopsis>
|
2000-11-25 18:17:30 +01:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>start</option></arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-l</option> <replaceable>filename</replaceable></arg>
|
2017-01-13 18:00:00 +01:00
|
|
|
<arg choice="opt"><option>-W</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-s</option></arg>
|
|
|
|
<arg choice="opt"><option>-o</option> <replaceable>options</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-p</option> <replaceable>path</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-c</option></arg>
|
2010-09-25 08:57:09 +02:00
|
|
|
</cmdsynopsis>
|
2007-11-10 22:48:51 +01:00
|
|
|
|
2010-09-25 08:57:09 +02:00
|
|
|
<cmdsynopsis>
|
2000-11-25 18:17:30 +01:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>stop</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-m</option>
|
2000-11-25 18:17:30 +01:00
|
|
|
<group choice="plain">
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="plain"><option>s[mart]</option></arg>
|
|
|
|
<arg choice="plain"><option>f[ast]</option></arg>
|
|
|
|
<arg choice="plain"><option>i[mmediate]</option></arg>
|
2000-11-25 18:17:30 +01:00
|
|
|
</group>
|
|
|
|
</arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-W</option></arg>
|
|
|
|
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-s</option></arg>
|
2010-09-25 08:57:09 +02:00
|
|
|
</cmdsynopsis>
|
2007-11-10 22:48:51 +01:00
|
|
|
|
2010-09-25 08:57:09 +02:00
|
|
|
<cmdsynopsis>
|
2000-11-25 18:17:30 +01:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>restart</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-m</option>
|
2000-11-25 18:17:30 +01:00
|
|
|
<group choice="plain">
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="plain"><option>s[mart]</option></arg>
|
|
|
|
<arg choice="plain"><option>f[ast]</option></arg>
|
|
|
|
<arg choice="plain"><option>i[mmediate]</option></arg>
|
2000-11-25 18:17:30 +01:00
|
|
|
</group>
|
|
|
|
</arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-W</option></arg>
|
|
|
|
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-s</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-o</option> <replaceable>options</replaceable></arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-c</option></arg>
|
2010-09-25 08:57:09 +02:00
|
|
|
</cmdsynopsis>
|
2007-11-10 22:48:51 +01:00
|
|
|
|
2011-02-16 03:28:48 +01:00
|
|
|
<cmdsynopsis>
|
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>reload</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-s</option></arg>
|
2011-02-16 03:28:48 +01:00
|
|
|
</cmdsynopsis>
|
|
|
|
|
2010-09-25 08:57:09 +02:00
|
|
|
<cmdsynopsis>
|
2000-11-25 18:17:30 +01:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>status</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
2010-09-25 08:57:09 +02:00
|
|
|
</cmdsynopsis>
|
2007-11-10 22:48:51 +01:00
|
|
|
|
2010-09-25 08:57:09 +02:00
|
|
|
<cmdsynopsis>
|
2001-09-21 23:10:56 +02:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>promote</option></arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
2017-01-13 18:00:00 +01:00
|
|
|
<arg choice="opt"><option>-W</option></arg>
|
2016-08-06 03:35:19 +02:00
|
|
|
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-s</option></arg>
|
2010-09-25 08:57:09 +02:00
|
|
|
</cmdsynopsis>
|
2007-11-10 22:48:51 +01:00
|
|
|
|
2018-09-01 18:46:49 +02:00
|
|
|
<cmdsynopsis>
|
|
|
|
<command>pg_ctl</command>
|
|
|
|
<arg choice="plain"><option>logrotate</option></arg>
|
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-s</option></arg>
|
|
|
|
</cmdsynopsis>
|
|
|
|
|
2010-09-25 08:57:09 +02:00
|
|
|
<cmdsynopsis>
|
2004-05-27 05:50:25 +02:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>kill</option></arg>
|
2011-04-28 11:51:02 +02:00
|
|
|
<arg choice="plain"><replaceable>signal_name</replaceable></arg>
|
|
|
|
<arg choice="plain"><replaceable>process_id</replaceable></arg>
|
2010-09-25 08:57:09 +02:00
|
|
|
</cmdsynopsis>
|
2007-11-10 22:48:51 +01:00
|
|
|
|
2017-04-20 20:41:48 +02:00
|
|
|
<para>On Microsoft Windows, also:</para>
|
|
|
|
|
2010-09-25 08:57:09 +02:00
|
|
|
<cmdsynopsis>
|
2005-02-21 03:13:26 +01:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>register</option></arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-N</option> <replaceable>servicename</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-U</option> <replaceable>username</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-P</option> <replaceable>password</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-S</option>
|
2010-10-15 19:30:03 +02:00
|
|
|
<group choice="plain">
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="plain"><option>a[uto]</option></arg>
|
|
|
|
<arg choice="plain"><option>d[emand]</option></arg>
|
2010-10-15 19:30:03 +02:00
|
|
|
</group>
|
|
|
|
</arg>
|
2017-04-20 20:41:48 +02:00
|
|
|
<arg choice="opt"><option>-e</option> <replaceable>source</replaceable></arg>
|
2017-01-13 18:00:00 +01:00
|
|
|
<arg choice="opt"><option>-W</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
|
|
|
|
<arg choice="opt"><option>-s</option></arg>
|
|
|
|
<arg choice="opt"><option>-o</option> <replaceable>options</replaceable></arg>
|
2010-09-25 08:57:09 +02:00
|
|
|
</cmdsynopsis>
|
2007-11-10 22:48:51 +01:00
|
|
|
|
2010-09-25 08:57:09 +02:00
|
|
|
<cmdsynopsis>
|
2005-02-21 03:13:26 +01:00
|
|
|
<command>pg_ctl</command>
|
2012-04-30 20:15:48 +02:00
|
|
|
<arg choice="plain"><option>unregister</option></arg>
|
2012-05-03 21:50:04 +02:00
|
|
|
<arg choice="opt"><option>-N</option> <replaceable>servicename</replaceable></arg>
|
2000-11-25 18:17:30 +01:00
|
|
|
</cmdsynopsis>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
|
|
|
|
<refsect1 id="app-pg-ctl-description">
|
|
|
|
<title>Description</title>
|
|
|
|
<para>
|
2009-12-10 07:32:28 +01:00
|
|
|
<application>pg_ctl</application> is a utility for initializing a
|
|
|
|
<productname>PostgreSQL</productname> database cluster, starting,
|
2003-03-24 15:32:51 +01:00
|
|
|
stopping, or restarting the <productname>PostgreSQL</productname>
|
2017-11-23 15:39:47 +01:00
|
|
|
database server (<xref linkend="app-postgres"/>), or displaying the
|
2003-03-24 15:32:51 +01:00
|
|
|
status of a running server. Although the server can be started
|
|
|
|
manually, <application>pg_ctl</application> encapsulates tasks such
|
|
|
|
as redirecting log output and properly detaching from the terminal
|
|
|
|
and process group. It also provides convenient options for
|
2001-11-28 21:49:10 +01:00
|
|
|
controlled shutdown.
|
2001-02-08 20:39:24 +01:00
|
|
|
</para>
|
|
|
|
|
2009-12-10 07:32:28 +01:00
|
|
|
<para>
|
2010-11-09 20:05:11 +01:00
|
|
|
The <option>init</option> or <option>initdb</option> mode creates a new
|
2017-04-20 20:41:48 +02:00
|
|
|
<productname>PostgreSQL</productname> database cluster, that is,
|
|
|
|
a collection of databases that will be managed by a single
|
2009-12-10 07:32:28 +01:00
|
|
|
server instance. This mode invokes the <command>initdb</command>
|
2017-11-23 15:39:47 +01:00
|
|
|
command. See <xref linkend="app-initdb"/> for details.
|
2009-12-10 07:32:28 +01:00
|
|
|
</para>
|
|
|
|
|
2001-02-08 20:39:24 +01:00
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
<option>start</option> mode launches a new server. The
|
2010-11-09 20:05:11 +01:00
|
|
|
server is started in the background, and its standard input is attached
|
2017-10-09 03:44:17 +02:00
|
|
|
to <filename>/dev/null</filename> (or <literal>nul</literal> on Windows).
|
2010-06-22 18:19:36 +02:00
|
|
|
On Unix-like systems, by default, the server's standard output and
|
2010-11-09 20:05:11 +01:00
|
|
|
standard error are sent to <application>pg_ctl</application>'s
|
2010-06-22 18:19:36 +02:00
|
|
|
standard output (not standard error). The standard output of
|
|
|
|
<application>pg_ctl</application> should then be redirected to a
|
|
|
|
file or piped to another process such as a log rotating program
|
2017-10-09 03:44:17 +02:00
|
|
|
like <application>rotatelogs</application>; otherwise <command>postgres</command>
|
2010-06-22 18:19:36 +02:00
|
|
|
will write its output to the controlling terminal (from the
|
|
|
|
background) and will not leave the shell's process group. On
|
|
|
|
Windows, by default the server's standard output and standard error
|
2010-11-09 20:05:11 +01:00
|
|
|
are sent to the terminal. These default behaviors can be changed
|
|
|
|
by using <option>-l</option> to append the server's output to a log file.
|
|
|
|
Use of either <option>-l</option> or output redirection is recommended.
|
2001-02-08 20:39:24 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
<option>stop</option> mode shuts down the server that is running in
|
|
|
|
the specified data directory. Three different
|
2001-02-08 20:39:24 +01:00
|
|
|
shutdown methods can be selected with the <option>-m</option>
|
Fix postmaster's behavior during smart shutdown.
Up to now, upon receipt of a SIGTERM ("smart shutdown" command), the
postmaster has immediately killed all "optional" background processes,
and subsequently refused to launch new ones while it's waiting for
foreground client processes to exit. No doubt this seemed like an OK
policy at some point; but it's a pretty bad one now, because it makes
for a seriously degraded environment for the remaining clients:
* Parallel queries are killed, and new ones fail to launch. (And our
parallel-query infrastructure utterly fails to deal with the case
in a reasonable way --- it just hangs waiting for workers that are
not going to arrive. There is more work needed in that area IMO.)
* Autovacuum ceases to function. We can tolerate that for awhile,
but if bulk-update queries continue to run in the surviving client
sessions, there's eventually going to be a mess. In the worst case
the system could reach a forced shutdown to prevent XID wraparound.
* The bgwriter and walwriter are also stopped immediately, likely
resulting in performance degradation.
Hence, let's rearrange things so that the only immediate change in
behavior is refusing to let in new normal connections. Once the last
normal connection is gone, shut everything down as though we'd received
a "fast" shutdown. To implement this, remove the PM_WAIT_BACKUP and
PM_WAIT_READONLY states, instead staying in PM_RUN or PM_HOT_STANDBY
while normal connections remain. A subsidiary state variable tracks
whether or not we're letting in new connections in those states.
This also allows having just one copy of the logic for killing child
processes in smart and fast shutdown modes. I moved that logic into
PostmasterStateMachine() by inventing a new state PM_STOP_BACKENDS.
Back-patch to 9.6 where parallel query was added. In principle
this'd be a good idea in 9.5 as well, but the risk/reward ratio
is not as good there, since lack of autovacuum is not a problem
during typical uses of smart shutdown.
Per report from Bharath Rupireddy.
Patch by me, reviewed by Thomas Munro
Discussion: https://postgr.es/m/CALj2ACXAZ5vKxT9P7P89D87i3MDO9bfS+_bjMHgnWJs8uwUOOw@mail.gmail.com
2020-08-14 19:26:57 +02:00
|
|
|
option. <quote>Smart</quote> mode disallows new connections, then waits
|
|
|
|
for all existing clients to disconnect and any online backup to finish.
|
2010-11-09 20:05:11 +01:00
|
|
|
If the server is in hot standby, recovery and streaming replication
|
2010-04-08 03:39:37 +02:00
|
|
|
will be terminated once all clients have disconnected.
|
2015-03-31 17:46:27 +02:00
|
|
|
<quote>Fast</quote> mode (the default) does not wait for clients to disconnect and
|
2008-04-23 15:44:59 +02:00
|
|
|
will terminate an online backup in progress. All active transactions are
|
2001-11-19 04:58:25 +01:00
|
|
|
rolled back and clients are forcibly disconnected, then the
|
2003-03-24 15:32:51 +01:00
|
|
|
server is shut down. <quote>Immediate</quote> mode will abort
|
2017-04-20 20:41:48 +02:00
|
|
|
all server processes immediately, without a clean shutdown. This choice
|
|
|
|
will lead to a crash-recovery cycle during the next server start.
|
2001-02-08 20:39:24 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<option>restart</option> mode effectively executes a stop followed
|
2006-06-18 17:38:37 +02:00
|
|
|
by a start. This allows changing the <command>postgres</command>
|
2017-04-20 20:41:48 +02:00
|
|
|
command-line options, or changing configuration-file options that
|
|
|
|
cannot be changed without restarting the server.
|
|
|
|
If relative paths were used on the command line during server
|
|
|
|
start, <option>restart</option> might fail unless
|
|
|
|
<application>pg_ctl</application> is executed in the same current
|
|
|
|
directory as it was during server start.
|
2001-02-08 20:39:24 +01:00
|
|
|
</para>
|
|
|
|
|
2001-09-21 23:10:56 +02:00
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
<option>reload</option> mode simply sends the
|
2017-10-09 03:44:17 +02:00
|
|
|
<command>postgres</command> server process a <systemitem>SIGHUP</systemitem>
|
2003-03-24 15:32:51 +01:00
|
|
|
signal, causing it to reread its configuration files
|
|
|
|
(<filename>postgresql.conf</filename>,
|
2017-04-20 20:41:48 +02:00
|
|
|
<filename>pg_hba.conf</filename>, etc.). This allows changing
|
|
|
|
configuration-file options that do not require a full server restart
|
2003-03-24 15:32:51 +01:00
|
|
|
to take effect.
|
2001-09-21 23:10:56 +02:00
|
|
|
</para>
|
|
|
|
|
2001-02-08 20:39:24 +01:00
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
<option>status</option> mode checks whether a server is running in
|
2017-04-20 20:41:48 +02:00
|
|
|
the specified data directory. If it is, the server's <acronym>PID</acronym>
|
|
|
|
and the command line options that were used to invoke it are displayed.
|
|
|
|
If the server is not running, <application>pg_ctl</application> returns
|
|
|
|
an exit status of 3. If an accessible data directory is not
|
|
|
|
specified, <application>pg_ctl</application> returns an exit status of 4.
|
2000-11-25 18:17:30 +01:00
|
|
|
</para>
|
2004-05-27 05:50:25 +02:00
|
|
|
|
2011-06-08 19:51:25 +02:00
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
<option>promote</option> mode commands the standby server that is
|
|
|
|
running in the specified data directory to end standby mode
|
|
|
|
and begin read-write operations.
|
2011-06-08 19:51:25 +02:00
|
|
|
</para>
|
|
|
|
|
2018-09-01 18:46:49 +02:00
|
|
|
<para>
|
|
|
|
<option>logrotate</option> mode rotates the server log file.
|
|
|
|
For details on how to use this mode with external log rotation tools, see
|
|
|
|
<xref linkend="logfile-maintenance"/>.
|
|
|
|
</para>
|
|
|
|
|
2004-05-27 05:50:25 +02:00
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
<option>kill</option> mode sends a signal to a specified process.
|
2017-10-09 03:44:17 +02:00
|
|
|
This is primarily valuable on <productname>Microsoft Windows</productname>
|
|
|
|
which does not have a built-in <application>kill</application> command. Use
|
|
|
|
<literal>--help</literal> to see a list of supported signal names.
|
2004-05-27 05:50:25 +02:00
|
|
|
</para>
|
2005-02-21 03:13:26 +01:00
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<option>register</option> mode registers the <productname>PostgreSQL</productname>
|
|
|
|
server as a system service on <productname>Microsoft Windows</productname>.
|
2017-04-20 20:41:48 +02:00
|
|
|
The <option>-S</option> option allows selection of service start type,
|
|
|
|
either <quote>auto</quote> (start service automatically on system startup)
|
|
|
|
or <quote>demand</quote> (start service on demand).
|
2005-02-21 03:13:26 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
<option>unregister</option> mode unregisters a system service
|
2017-10-09 03:44:17 +02:00
|
|
|
on <productname>Microsoft Windows</productname>. This undoes the effects of the
|
2005-02-21 03:13:26 +01:00
|
|
|
<option>register</option> command.
|
|
|
|
</para>
|
2002-10-12 01:03:48 +02:00
|
|
|
</refsect1>
|
2000-11-25 18:17:30 +01:00
|
|
|
|
2002-10-12 01:03:48 +02:00
|
|
|
<refsect1 id="app-pg-ctl-options">
|
|
|
|
<title>Options</title>
|
|
|
|
|
2000-04-08 04:16:26 +02:00
|
|
|
<variablelist>
|
2007-11-10 15:07:18 +01:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><option>-c</option></term>
|
2017-04-20 20:41:48 +02:00
|
|
|
<term><option>--core-files</option></term>
|
2007-11-10 15:07:18 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Attempt to allow server crashes to produce core files, on platforms
|
2010-11-09 20:05:11 +01:00
|
|
|
where this is possible, by lifting any soft resource limit placed on
|
|
|
|
core files.
|
|
|
|
This is useful in debugging or diagnosing problems by allowing a
|
2007-11-10 15:07:18 +01:00
|
|
|
stack trace to be obtained from a failed server process.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2000-04-08 04:16:26 +02:00
|
|
|
<varlistentry>
|
2003-03-24 15:32:51 +01:00
|
|
|
<term><option>-D <replaceable class="parameter">datadir</replaceable></option></term>
|
2016-10-19 18:00:00 +02:00
|
|
|
<term><option>--pgdata=<replaceable class="parameter">datadir</replaceable></option></term>
|
2000-04-08 04:16:26 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2012-08-16 04:59:37 +02:00
|
|
|
Specifies the file system location of the database configuration files. If
|
2017-04-20 20:41:48 +02:00
|
|
|
this option is omitted, the environment variable
|
2007-02-22 00:21:12 +01:00
|
|
|
<envar>PGDATA</envar> is used.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2003-03-24 15:32:51 +01:00
|
|
|
<term><option>-l <replaceable class="parameter">filename</replaceable></option></term>
|
2016-10-19 18:00:00 +02:00
|
|
|
<term><option>--log=<replaceable class="parameter">filename</replaceable></option></term>
|
2000-04-08 04:16:26 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2001-02-08 20:39:24 +01:00
|
|
|
Append the server log output to
|
|
|
|
<replaceable>filename</replaceable>. If the file does not
|
2017-10-09 03:44:17 +02:00
|
|
|
exist, it is created. The <systemitem>umask</systemitem> is set to 077,
|
2010-11-09 20:05:11 +01:00
|
|
|
so access to the log file is disallowed to other users by default.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2003-03-24 15:32:51 +01:00
|
|
|
<term><option>-m <replaceable class="parameter">mode</replaceable></option></term>
|
2016-10-19 18:00:00 +02:00
|
|
|
<term><option>--mode=<replaceable class="parameter">mode</replaceable></option></term>
|
2000-04-08 04:16:26 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-02-22 00:21:12 +01:00
|
|
|
Specifies the shutdown mode. <replaceable>mode</replaceable>
|
|
|
|
can be <literal>smart</literal>, <literal>fast</literal>, or
|
|
|
|
<literal>immediate</literal>, or the first letter of one of
|
2017-04-20 20:41:48 +02:00
|
|
|
these three. If this option is omitted, <literal>fast</literal> is
|
|
|
|
the default.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2003-03-24 15:32:51 +01:00
|
|
|
<term><option>-o <replaceable class="parameter">options</replaceable></option></term>
|
2016-10-19 18:00:00 +02:00
|
|
|
<term><option>--options=<replaceable class="parameter">options</replaceable></option></term>
|
2000-04-08 04:16:26 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
Specifies options to be passed directly to the
|
2017-04-20 20:41:48 +02:00
|
|
|
<command>postgres</command> command.
|
2017-10-09 03:44:17 +02:00
|
|
|
<option>-o</option> can be specified multiple times, with all the given
|
2017-04-20 20:41:48 +02:00
|
|
|
options being passed through.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
The <replaceable>options</replaceable> should usually be surrounded by single or
|
2017-04-20 20:41:48 +02:00
|
|
|
double quotes to ensure that they are passed through as a group.
|
2010-11-09 20:05:11 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><option>-o <replaceable class="parameter">initdb-options</replaceable></option></term>
|
2016-10-19 18:00:00 +02:00
|
|
|
<term><option>--options=<replaceable class="parameter">initdb-options</replaceable></option></term>
|
2010-11-09 20:05:11 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Specifies options to be passed directly to the
|
|
|
|
<command>initdb</command> command.
|
2017-10-09 03:44:17 +02:00
|
|
|
<option>-o</option> can be specified multiple times, with all the given
|
2017-04-20 20:41:48 +02:00
|
|
|
options being passed through.
|
2010-11-09 20:05:11 +01:00
|
|
|
</para>
|
|
|
|
<para>
|
2018-08-25 18:01:53 +02:00
|
|
|
The <replaceable>initdb-options</replaceable> should usually be surrounded by single or
|
2017-04-20 20:41:48 +02:00
|
|
|
double quotes to ensure that they are passed through as a group.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2003-03-24 15:32:51 +01:00
|
|
|
<term><option>-p <replaceable class="parameter">path</replaceable></option></term>
|
2000-04-08 04:16:26 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2007-02-22 00:21:12 +01:00
|
|
|
Specifies the location of the <filename>postgres</filename>
|
|
|
|
executable. By default the <filename>postgres</filename> executable is taken from the same
|
|
|
|
directory as <command>pg_ctl</command>, or failing that, the hard-wired
|
|
|
|
installation directory. It is not necessary to use this
|
|
|
|
option unless you are doing something unusual and get errors
|
|
|
|
that the <filename>postgres</filename> executable was not found.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
2009-12-10 07:32:28 +01:00
|
|
|
|
|
|
|
<para>
|
|
|
|
In <literal>init</literal> mode, this option analogously
|
|
|
|
specifies the location of the <filename>initdb</filename>
|
|
|
|
executable.
|
|
|
|
</para>
|
2000-04-08 04:16:26 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2003-03-24 15:32:51 +01:00
|
|
|
<term><option>-s</option></term>
|
2012-04-14 11:40:35 +02:00
|
|
|
<term><option>--silent</option></term>
|
2000-04-08 04:16:26 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2010-11-09 20:05:11 +01:00
|
|
|
Print only errors, no informational messages.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2007-11-10 22:48:51 +01:00
|
|
|
<varlistentry>
|
2017-04-20 20:41:48 +02:00
|
|
|
<term><option>-t <replaceable class="parameter">seconds</replaceable></option></term>
|
|
|
|
<term><option>--timeout=<replaceable class="parameter">seconds</replaceable></option></term>
|
2007-11-10 22:48:51 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
Specifies the maximum number of seconds to wait when waiting for an
|
|
|
|
operation to complete (see option <option>-w</option>). Defaults to
|
2017-10-09 03:44:17 +02:00
|
|
|
the value of the <envar>PGCTLTIMEOUT</envar> environment variable or, if
|
2017-04-20 20:41:48 +02:00
|
|
|
not set, to 60 seconds.
|
2007-11-10 22:48:51 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2012-06-18 01:44:00 +02:00
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-V</option></term>
|
|
|
|
<term><option>--version</option></term>
|
2012-06-18 01:44:00 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Print the <application>pg_ctl</application> version and exit.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2000-04-08 04:16:26 +02:00
|
|
|
<varlistentry>
|
2003-03-24 15:32:51 +01:00
|
|
|
<term><option>-w</option></term>
|
2016-10-19 18:00:00 +02:00
|
|
|
<term><option>--wait</option></term>
|
2000-04-08 04:16:26 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
Wait for the operation to complete. This is supported for the
|
2016-08-06 03:35:19 +02:00
|
|
|
modes <literal>start</literal>, <literal>stop</literal>,
|
|
|
|
<literal>restart</literal>, <literal>promote</literal>,
|
2017-01-13 18:00:00 +01:00
|
|
|
and <literal>register</literal>, and is the default for those modes.
|
2016-08-06 03:35:19 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2018-01-23 18:41:35 +01:00
|
|
|
When waiting, <command>pg_ctl</command> repeatedly checks the
|
|
|
|
server's <acronym>PID</acronym> file, sleeping for a short amount
|
|
|
|
of time between checks. Startup is considered complete when
|
|
|
|
the <acronym>PID</acronym> file indicates that the server is ready to
|
|
|
|
accept connections. Shutdown is considered complete when the server
|
|
|
|
removes the <acronym>PID</acronym> file.
|
2010-12-24 15:45:15 +01:00
|
|
|
<command>pg_ctl</command> returns an exit code based on the
|
|
|
|
success of the startup or shutdown.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
2017-05-01 18:10:17 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
If the operation does not complete within the timeout (see
|
|
|
|
option <option>-t</option>), then <command>pg_ctl</command> exits with
|
|
|
|
a nonzero exit status. But note that the operation might continue in
|
|
|
|
the background and eventually succeed.
|
|
|
|
</para>
|
2000-04-08 04:16:26 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2001-04-27 03:31:56 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
2003-03-24 15:32:51 +01:00
|
|
|
<term><option>-W</option></term>
|
2016-10-19 18:00:00 +02:00
|
|
|
<term><option>--no-wait</option></term>
|
2001-04-27 03:31:56 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
Do not wait for the operation to complete. This is the opposite of
|
|
|
|
the option <option>-w</option>.
|
2001-04-27 03:31:56 +02:00
|
|
|
</para>
|
2017-01-13 18:00:00 +01:00
|
|
|
|
|
|
|
<para>
|
|
|
|
If waiting is disabled, the requested action is triggered, but there
|
|
|
|
is no feedback about its success. In that case, the server log file
|
|
|
|
or an external monitoring system would have to be used to check the
|
|
|
|
progress and success of the operation.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
In prior releases of PostgreSQL, this was the default except for
|
|
|
|
the <literal>stop</literal> mode.
|
|
|
|
</para>
|
2001-04-27 03:31:56 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2012-06-18 01:44:00 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
2017-10-09 03:44:17 +02:00
|
|
|
<term><option>-?</option></term>
|
|
|
|
<term><option>--help</option></term>
|
2012-06-18 01:44:00 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Show help about <application>pg_ctl</application> command line
|
|
|
|
arguments, and exit.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2005-02-21 03:13:26 +01:00
|
|
|
</variablelist>
|
|
|
|
|
2017-04-20 20:41:48 +02:00
|
|
|
<para>
|
|
|
|
If an option is specified that is valid, but not relevant to the selected
|
|
|
|
operating mode, <application>pg_ctl</application> ignores it.
|
|
|
|
</para>
|
|
|
|
|
2006-12-02 01:34:52 +01:00
|
|
|
<refsect2 id="app-pg-ctl-windows-options">
|
|
|
|
<title>Options for Windows</title>
|
|
|
|
|
2005-02-21 03:13:26 +01:00
|
|
|
<variablelist>
|
2014-07-17 12:42:08 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-e <replaceable class="parameter">source</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Name of the event source for <application>pg_ctl</application> to use
|
|
|
|
for logging to the event log when running as a Windows service. The
|
|
|
|
default is <literal>PostgreSQL</literal>. Note that this only controls
|
2017-04-20 20:41:48 +02:00
|
|
|
messages sent from <application>pg_ctl</application> itself; once
|
2014-07-17 12:42:08 +02:00
|
|
|
started, the server will use the event source specified
|
2017-11-23 15:39:47 +01:00
|
|
|
by its <xref linkend="guc-event-source"/> parameter. Should the server
|
2017-04-20 20:41:48 +02:00
|
|
|
fail very early in startup, before that parameter has been set,
|
|
|
|
it might also log using the default event
|
|
|
|
source name <literal>PostgreSQL</literal>.
|
2014-07-17 12:42:08 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2005-02-21 03:13:26 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><option>-N <replaceable class="parameter">servicename</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
Name of the system service to register. This name will be used
|
2005-02-21 03:13:26 +01:00
|
|
|
as both the service name and the display name.
|
2017-04-20 20:41:48 +02:00
|
|
|
The default is <literal>PostgreSQL</literal>.
|
2005-02-21 03:13:26 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2010-11-09 20:05:11 +01:00
|
|
|
<term><option>-P <replaceable class="parameter">password</replaceable></option></term>
|
2005-02-21 03:13:26 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
Password for the user to run the service as.
|
2005-02-21 03:13:26 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2010-10-15 19:30:03 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><option>-S <replaceable class="parameter">start-type</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
Start type of the system service. <replaceable>start-type</replaceable> can
|
2010-10-15 19:30:03 +02:00
|
|
|
be <literal>auto</literal>, or <literal>demand</literal>, or
|
2017-04-20 20:41:48 +02:00
|
|
|
the first letter of one of these two. If this option is omitted,
|
|
|
|
<literal>auto</literal> is the default.
|
2010-10-15 19:30:03 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2011-06-08 19:51:25 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><option>-U <replaceable class="parameter">username</replaceable></option></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
User name for the user to run the service as. For domain users, use the
|
2011-06-08 19:51:25 +02:00
|
|
|
format <literal>DOMAIN\username</literal>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2005-02-21 03:13:26 +01:00
|
|
|
</variablelist>
|
2006-12-02 01:34:52 +01:00
|
|
|
</refsect2>
|
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Environment</title>
|
2000-04-08 04:16:26 +02:00
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
<variablelist>
|
2016-02-11 02:34:02 +01:00
|
|
|
<varlistentry>
|
|
|
|
<term><envar>PGCTLTIMEOUT</envar></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Default limit on the number of seconds to wait when waiting for startup
|
|
|
|
or shutdown to complete. If not set, the default is 60 seconds.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
<varlistentry>
|
|
|
|
<term><envar>PGDATA</envar></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-03-20 06:00:14 +01:00
|
|
|
Default data directory location.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
</variablelist>
|
|
|
|
|
2017-04-20 20:41:48 +02:00
|
|
|
<para>
|
|
|
|
Most <command>pg_ctl</command> modes require knowing the data directory
|
2017-10-09 03:44:17 +02:00
|
|
|
location; therefore, the <option>-D</option> option is required
|
2017-04-20 20:41:48 +02:00
|
|
|
unless <envar>PGDATA</envar> is set.
|
|
|
|
</para>
|
|
|
|
|
2002-07-28 17:22:21 +02:00
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<command>pg_ctl</command>, like most other <productname>PostgreSQL</productname>
|
2010-11-09 20:05:11 +01:00
|
|
|
utilities,
|
2017-10-09 03:44:17 +02:00
|
|
|
also uses the environment variables supported by <application>libpq</application>
|
2017-11-23 15:39:47 +01:00
|
|
|
(see <xref linkend="libpq-envars"/>).
|
2017-04-20 20:41:48 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
For additional variables that affect the server,
|
2017-11-23 15:39:47 +01:00
|
|
|
see <xref linkend="app-postgres"/>.
|
2002-07-28 17:22:21 +02:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Files</title>
|
2000-04-08 04:16:26 +02:00
|
|
|
|
2003-03-20 06:00:14 +01:00
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><filename>postmaster.pid</filename></term>
|
|
|
|
|
|
|
|
<listitem>
|
2003-03-24 15:32:51 +01:00
|
|
|
<para>
|
2017-04-20 20:41:48 +02:00
|
|
|
<application>pg_ctl</application> examines this file in the data
|
|
|
|
directory to determine whether the server is currently running.
|
2003-03-20 06:00:14 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><filename>postmaster.opts</filename></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>If this file exists in the data directory,
|
2010-11-09 20:05:11 +01:00
|
|
|
<application>pg_ctl</application> (in <option>restart</option> mode)
|
2006-06-18 17:38:37 +02:00
|
|
|
will pass the contents of the file as options to
|
2010-11-09 20:05:11 +01:00
|
|
|
<application>postgres</application>, unless overridden
|
|
|
|
by the <option>-o</option> option. The contents of this file
|
2003-03-20 06:00:14 +01:00
|
|
|
are also displayed in <option>status</option> mode.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
</variablelist>
|
2002-07-28 17:22:21 +02:00
|
|
|
</refsect1>
|
|
|
|
|
2000-04-08 04:16:26 +02:00
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refsect1 id="r1-app-pgctl-2">
|
2001-02-08 20:39:24 +01:00
|
|
|
<title>Examples</title>
|
2000-04-08 04:16:26 +02:00
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refsect2 id="r2-app-pgctl-3">
|
2003-03-24 15:32:51 +01:00
|
|
|
<title>Starting the Server</title>
|
2000-04-08 04:16:26 +02:00
|
|
|
|
|
|
|
<para>
|
2011-03-09 15:18:44 +01:00
|
|
|
To start the server, waiting until the server is
|
|
|
|
accepting connections:
|
2000-11-25 18:17:30 +01:00
|
|
|
<screen>
|
2017-01-13 18:00:00 +01:00
|
|
|
<prompt>$</prompt> <userinput>pg_ctl start</userinput>
|
2000-11-25 18:17:30 +01:00
|
|
|
</screen>
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2011-03-09 15:18:44 +01:00
|
|
|
To start the server using port 5433, and
|
2000-04-08 04:16:26 +02:00
|
|
|
running without <function>fsync</function>, use:
|
2000-11-25 18:17:30 +01:00
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" start</userinput>
|
2011-08-07 09:49:45 +02:00
|
|
|
</screen></para>
|
2000-04-08 04:16:26 +02:00
|
|
|
</refsect2>
|
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refsect2 id="r2-app-pgctl-4">
|
2003-03-24 15:32:51 +01:00
|
|
|
<title>Stopping the Server</title>
|
2000-04-08 04:16:26 +02:00
|
|
|
<para>
|
2010-12-22 15:11:33 +01:00
|
|
|
To stop the server, use:
|
2000-11-25 18:17:30 +01:00
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_ctl stop</userinput>
|
|
|
|
</screen>
|
2010-12-22 15:11:33 +01:00
|
|
|
The <option>-m</option> option allows control over
|
2011-03-09 15:18:44 +01:00
|
|
|
<emphasis>how</emphasis> the server shuts down:
|
|
|
|
<screen>
|
2017-01-13 18:00:00 +01:00
|
|
|
<prompt>$</prompt> <userinput>pg_ctl stop -m smart</userinput>
|
2011-08-07 09:49:45 +02:00
|
|
|
</screen></para>
|
2000-04-08 04:16:26 +02:00
|
|
|
</refsect2>
|
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refsect2 id="r2-app-pgctl-5">
|
2003-03-24 15:32:51 +01:00
|
|
|
<title>Restarting the Server</title>
|
2000-04-08 04:16:26 +02:00
|
|
|
|
|
|
|
<para>
|
2003-03-24 15:32:51 +01:00
|
|
|
Restarting the server is almost equivalent to stopping the
|
2017-04-20 20:41:48 +02:00
|
|
|
server and starting it again, except that by default,
|
|
|
|
<command>pg_ctl</command> saves and reuses the command line options that
|
|
|
|
were passed to the previously-running instance. To restart
|
|
|
|
the server using the same options as before, use:
|
2000-11-25 18:17:30 +01:00
|
|
|
<screen>
|
2017-01-13 18:00:00 +01:00
|
|
|
<prompt>$</prompt> <userinput>pg_ctl restart</userinput>
|
2000-11-25 18:17:30 +01:00
|
|
|
</screen>
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
But if <option>-o</option> is specified, that replaces any previous options.
|
|
|
|
To restart using port 5433, disabling <function>fsync</function> upon restart:
|
2000-11-25 18:17:30 +01:00
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" restart</userinput>
|
2011-08-07 09:49:45 +02:00
|
|
|
</screen></para>
|
2000-04-08 04:16:26 +02:00
|
|
|
</refsect2>
|
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refsect2 id="r2-app-pgctl-6">
|
2003-03-24 15:32:51 +01:00
|
|
|
<title>Showing the Server Status</title>
|
2000-04-08 04:16:26 +02:00
|
|
|
|
|
|
|
<para>
|
2010-12-22 15:11:33 +01:00
|
|
|
Here is sample status output from
|
2000-11-25 18:17:30 +01:00
|
|
|
<application>pg_ctl</application>:
|
|
|
|
<screen>
|
|
|
|
<prompt>$</prompt> <userinput>pg_ctl status</userinput>
|
|
|
|
<computeroutput>
|
2010-12-11 05:22:50 +01:00
|
|
|
pg_ctl: server is running (PID: 13718)
|
|
|
|
/usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data" "-p" "5433" "-B" "128"
|
2018-05-21 20:41:27 +02:00
|
|
|
</computeroutput></screen>
|
2017-04-20 20:41:48 +02:00
|
|
|
The second line is the command that would be invoked in restart mode.
|
2000-04-08 04:16:26 +02:00
|
|
|
</para>
|
|
|
|
</refsect2>
|
|
|
|
</refsect1>
|
2001-02-08 20:39:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
|
2009-12-10 07:32:28 +01:00
|
|
|
<simplelist type="inline">
|
2017-11-23 15:39:47 +01:00
|
|
|
<member><xref linkend="app-initdb"/></member>
|
|
|
|
<member><xref linkend="app-postgres"/></member>
|
2009-12-10 07:32:28 +01:00
|
|
|
</simplelist>
|
2001-02-08 20:39:24 +01:00
|
|
|
</refsect1>
|
|
|
|
|
2000-04-08 04:16:26 +02:00
|
|
|
</refentry>
|