]> granicus.if.org Git - postgresql/blobdiff - doc/src/sgml/ref/pg_ctl-ref.sgml
Add option to pg_ctl to choose event source for logging
[postgresql] / doc / src / sgml / ref / pg_ctl-ref.sgml
index 783062333f38d7a08091d94b8ee44fc01d666d33..23681294b87d767f5d085936ac482bec743c26d5 100644 (file)
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_ctl-ref.sgml,v 1.2 2000/10/08 13:22:24 petere Exp $
-Postgres documentation
+doc/src/sgml/ref/pg_ctl-ref.sgml
+PostgreSQL documentation
 -->
 
 <refentry id="app-pg-ctl">
+ <indexterm zone="app-pg-ctl">
+  <primary>pg_ctl</primary>
+ </indexterm>
+
  <refmeta>
-  <refentrytitle id="app-pg-ctl-title">
-   <application>pg_ctl</application>
-  </refentrytitle>
+  <refentrytitle><application>pg_ctl</application></refentrytitle>
+  <manvolnum>1</manvolnum>
   <refmiscinfo>Application</refmiscinfo>
  </refmeta>
 
  <refnamediv>
-  <refname>
-   <application>pg_ctl</application>
-  </refname>
-  <refpurpose>
-   Starts, stops, and restarts postmaster
-  </refpurpose>
+  <refname>pg_ctl</refname>
+  <refpurpose>initialize, start, stop, or control a <productname>PostgreSQL</productname> server</refpurpose>
  </refnamediv>
 
  <refsynopsisdiv>
-  <refsynopsisdivinfo>
-   <date>2000-04-05</date>
-  </refsynopsisdivinfo>
-
-  <synopsis>
-pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>][-p <replaceable class="parameter">path</replaceable>] [-o "<replaceable class="parameter">options</replaceable>"] start
-pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>] [-m [s[mart]|f[ast]|i[mmediate]]] stop
-pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>] [-m [s[mart]|f[ast]|i[mmediate]]
-    [-o "<replaceable class="parameter">options</replaceable>"] restart
-pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
-  </synopsis>
-
-  <refsect2 id="R2-APP-PGCTL-1">
-   <title>
-    Inputs
-   </title>
-   <para>
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>init[db]</option></arg>
+   <arg choice="opt"><option>-s</option></arg>
+   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
+   <arg choice="opt"><option>-o</option> <replaceable>initdb-options</replaceable></arg>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>start</option></arg>
+   <arg choice="opt"><option>-w</option></arg>
+   <arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
+   <arg choice="opt"><option>-s</option></arg>
+   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
+   <arg choice="opt"><option>-l</option> <replaceable>filename</replaceable></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>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>stop</option></arg>
+   <arg choice="opt"><option>-W</option></arg>
+   <arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
+   <arg choice="opt"><option>-s</option></arg>
+   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
+   <arg choice="opt"><option>-m</option>
+     <group choice="plain">
+       <arg choice="plain"><option>s[mart]</option></arg>
+       <arg choice="plain"><option>f[ast]</option></arg>
+       <arg choice="plain"><option>i[mmediate]</option></arg>
+     </group>
+   </arg>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>restart</option></arg>
+   <arg choice="opt"><option>-w</option></arg>
+   <arg choice="opt"><option>-t</option> <replaceable>seconds</replaceable></arg>
+   <arg choice="opt"><option>-s</option></arg>
+   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
+   <arg choice="opt"><option>-c</option></arg>
+   <arg choice="opt"><option>-m</option>
+     <group choice="plain">
+       <arg choice="plain"><option>s[mart]</option></arg>
+       <arg choice="plain"><option>f[ast]</option></arg>
+       <arg choice="plain"><option>i[mmediate]</option></arg>
+     </group>
+   </arg>
+   <arg choice="opt"><option>-o</option> <replaceable>options</replaceable></arg>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>reload</option></arg>
+   <arg choice="opt"><option>-s</option></arg>
+   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>status</option></arg>
+   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>promote</option></arg>
+   <arg choice="opt"><option>-s</option></arg>
+   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>kill</option></arg>
+   <arg choice="plain"><replaceable>signal_name</replaceable></arg>
+   <arg choice="plain"><replaceable>process_id</replaceable></arg>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>register</option></arg>
+   <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>-D</option> <replaceable>datadir</replaceable></arg>
+   <arg choice="opt"><option>-S</option>
+     <group choice="plain">
+       <arg choice="plain"><option>a[uto]</option></arg>
+       <arg choice="plain"><option>d[emand]</option></arg>
+     </group>
+   </arg>
+   <arg choice="opt"><option>-w</option></arg>
+   <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>
+  </cmdsynopsis>
+
+  <cmdsynopsis>
+   <command>pg_ctl</command>
+   <arg choice="plain"><option>unregister</option></arg>
+   <arg choice="opt"><option>-N</option> <replaceable>servicename</replaceable></arg>
+  </cmdsynopsis>
+ </refsynopsisdiv>
+
+
+ <refsect1 id="app-pg-ctl-description">
+  <title>Description</title>
+  <para>
+   <application>pg_ctl</application> is a utility for initializing a
+   <productname>PostgreSQL</productname> database cluster, starting,
+   stopping, or restarting the <productname>PostgreSQL</productname>
+   database server (<xref linkend="app-postgres">), or displaying the
+   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
+   controlled shutdown.
+  </para>
+
+  <para>
+   The <option>init</option> or <option>initdb</option> mode creates a new
+   <productname>PostgreSQL</productname> database cluster.  A database
+   cluster is a collection of databases that are managed by a single
+   server instance.  This mode invokes the <command>initdb</command>
+   command.  See <xref linkend="app-initdb"> for details.
+  </para>
+
+  <para>
+   In <option>start</option> mode, a new server is launched.  The
+   server is started in the background, and its standard input is attached
+   to <filename>/dev/null</filename> (or <literal>nul</> on Windows).
+   On Unix-like systems, by default, the server's standard output and
+   standard error are sent to <application>pg_ctl</application>'s
+   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
+   like <application>rotatelogs</>; otherwise <command>postgres</command>
+   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
+   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.
+  </para>
+
+  <para>
+   In <option>stop</option> mode, the server that is running in
+   the specified data directory is shut down.  Three different
+   shutdown methods can be selected with the <option>-m</option>
+   option.  <quote>Smart</quote> mode (the default) waits for all active
+   clients to disconnect and any online backup to finish.
+   If the server is in hot standby, recovery and streaming replication
+   will be terminated once all clients have disconnected.
+   <quote>Fast</quote> mode does not wait for clients to disconnect and
+   will terminate an online backup in progress.  All active transactions are
+   rolled back and clients are forcibly disconnected, then the
+   server is shut down.  <quote>Immediate</quote> mode will abort
+   all server processes immediately, without a clean shutdown.
+   This will lead to a crash-recovery run on the next restart.
+  </para>
+
+  <para>
+   <option>restart</option> mode effectively executes a stop followed
+   by a start.  This allows changing the <command>postgres</command>
+   command-line options.  <option>restart</option> might fail if
+   relative paths specified were specified on the command-line during
+   server start.
+  </para>
+
+  <para>
+   <option>reload</option> mode simply sends the
+   <command>postgres</command> process a <systemitem>SIGHUP</>
+   signal, causing it to reread its configuration files
+   (<filename>postgresql.conf</filename>,
+   <filename>pg_hba.conf</filename>, etc.).  This allows changing of
+   configuration-file options that do not require a complete restart
+   to take effect.
+  </para>
+
+  <para>
+   <option>status</option> mode checks whether a server is running in
+   the specified data directory. If it is, the <acronym>PID</acronym>
+   and the command line options that were used to invoke it are
+   displayed.  If the server is not running, the process returns an
+   exit status of 3.  If an accessible data directory is not specified,
+   the process returns an exit status of 4.
+  </para>
+
+  <para>
+   In <option>promote</option> mode, the standby server that is
+   running in the specified data directory is commanded to exit
+   recovery and begin read-write operations.
+  </para>
+
+  <para>
+   <option>kill</option> mode allows you to send a signal to a specified
+    process.  This is particularly valuable for <productname>Microsoft Windows</>
+    which does not have a <application>kill</> command.  Use
+    <literal>--help</> to see a list of supported signal names.
+  </para>
+
+  <para>
+   <option>register</option> mode allows you to register a system service
+   on <productname>Microsoft Windows</>.  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).
+  </para>
+
+  <para>
+   <option>unregister</option> mode allows you to unregister a system service
+   on <productname>Microsoft Windows</>.  This undoes the effects of the
+   <option>register</option> command.
+  </para>
+ </refsect1>
+
+ <refsect1 id="app-pg-ctl-options">
+  <title>Options</title>
 
     <variablelist>
+
      <varlistentry>
-      <term>-w</term>
+      <term><option>-c</option></term>
+      <term><option>--core-file</option></term>
       <listitem>
        <para>
-       Wait for the database server to come up, by
-       watching for creation of the pid file (PGDATA/postmaster.pid).
-       Times out after 60 seconds.
+        Attempt to allow server crashes to produce core files, on platforms
+        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
+        stack trace to be obtained from a failed server process.
        </para>
       </listitem>
      </varlistentry>
 
      <varlistentry>
-      <term>-D <replaceable class="parameter">datadir</replaceable></term>
+      <term><option>-D <replaceable class="parameter">datadir</replaceable></option></term>
+      <term><option>--pgdata <replaceable class="parameter">datadir</replaceable></option></term>
       <listitem>
        <para>
-       Specifies the database location for this database installation.
+        Specifies the file system location of the database configuration files.  If
+        this is omitted, the environment variable
+        <envar>PGDATA</envar> is used.
        </para>
       </listitem>
      </varlistentry>
 
      <varlistentry>
-      <term>-p <replaceable class="parameter">path</replaceable></term>
+      <term><option>-l <replaceable class="parameter">filename</replaceable></option></term>
+      <term><option>--log <replaceable class="parameter">filename</replaceable></option></term>
       <listitem>
        <para>
-       Specifies the path to the postmaster image.
+        Append the server log output to
+        <replaceable>filename</replaceable>.  If the file does not
+        exist, it is created.  The <systemitem>umask</> is set to 077,
+        so access to the log file is disallowed to other users by default.
        </para>
       </listitem>
      </varlistentry>
 
      <varlistentry>
-      <term>-o "<replaceable class="parameter">options</replaceable>"</term>
+      <term><option>-m <replaceable class="parameter">mode</replaceable></option></term>
+      <term><option>--mode <replaceable class="parameter">mode</replaceable></option></term>
       <listitem>
        <para>
-        Specifies options to be passed directly to
-       <application>postmaster</application>.
+        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
+        these three.  If this is omitted, <literal>smart</literal> is used.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
+      <term><option>-o <replaceable class="parameter">options</replaceable></option></term>
+      <listitem>
+       <para>
+        Specifies options to be passed directly to the
+        <command>postgres</command> command.
        </para>
        <para>
-       The parameters are usually surrounded by single or double
-       quotes to ensure that they are passed through as a group.
+        The options should usually be surrounded by single or double
+        quotes to ensure that they are passed through as a group.
        </para>
       </listitem>
      </varlistentry>
 
      <varlistentry>
-      <term>-m <replaceable class="parameter">mode</replaceable></term>
+      <term><option>-o <replaceable class="parameter">initdb-options</replaceable></option></term>
       <listitem>
        <para>
-       Specifies the shutdown mode.
-
-       <variablelist>
-        <varlistentry>
-         <term>smart</term>
-         <term>s</term>
-         <listitem>
-          <para>
-           smart mode waits for all
-           the clients to logout. This is the default.
-          </para>
-         </listitem>
-        </varlistentry>
-
-        <varlistentry>
-         <term>fast</term>
-         <term>f</term>
-         <listitem>
-          <para>
-           Fast mode sends SIGTERM to the backends; that means
-           active transactions get rolled back.
-          </para>
-         </listitem>
-        </varlistentry>
-
-        <varlistentry>
-         <term>immediate</term>
-         <term>i</term>
-         <listitem>
-          <para>
-           Immediate mode sends SIGUSR1
-           to the backends and lets them abort. In this case, database recovery
-           will be necessary on the next start-up.
-          </para>
-         </listitem>
-        </varlistentry>
-       </variablelist>
+        Specifies options to be passed directly to the
+        <command>initdb</command> command.
+       </para>
+       <para>
+        The options should usually be surrounded by single or double
+        quotes to ensure that they are passed through as a group.
        </para>
       </listitem>
      </varlistentry>
 
      <varlistentry>
-      <term>start</term>
+      <term><option>-p <replaceable class="parameter">path</replaceable></option></term>
       <listitem>
        <para>
-       Start up <application>postmaster</application>.
+        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.
+       </para>
+
+       <para>
+        In <literal>init</literal> mode, this option analogously
+        specifies the location of the <filename>initdb</filename>
+        executable.
        </para>
       </listitem>
      </varlistentry>
 
      <varlistentry>
-      <term>stop</term>
+      <term><option>-s</option></term>
+      <term><option>--silent</option></term>
       <listitem>
        <para>
-       Shut down <application>postmaster</application>.
+        Print only errors, no informational messages.
        </para>
       </listitem>
      </varlistentry>
 
      <varlistentry>
-      <term>restart</term>
+      <term><option>-t</option></term>
+      <term><option>--timeout</option></term>
       <listitem>
        <para>
-       Restart the <application>postmaster</application>, performing
-       a stop/start sequence.
+        The maximum number of seconds to wait when waiting for startup or
+        shutdown to complete.  The default is 60 seconds.
        </para>
       </listitem>
      </varlistentry>
 
      <varlistentry>
-      <term>status</term>
+      <term><option>-V</></term>
+      <term><option>--version</></term>
+       <listitem>
+        <para>
+         Print the <application>pg_ctl</application> version and exit.
+        </para>
+       </listitem>
+     </varlistentry>
+
+     <varlistentry>
+      <term><option>-w</option></term>
       <listitem>
        <para>
-       Show the current state of <application>postmaster</application>.
+        Wait for the startup or shutdown to complete.
+        Waiting is the default option for shutdowns, but not startups.
+        When waiting for startup, <command>pg_ctl</command> repeatedly
+        attempts to connect to the server.
+        When waiting for shutdown, <command>pg_ctl</command> waits for
+        the server to remove its <acronym>PID</acronym> file.
+        This option allows the entry of an <acronym>SSL</> passphrase on startup.
+        <command>pg_ctl</command> returns an exit code based on the
+        success of the startup or shutdown.
        </para>
       </listitem>
      </varlistentry>
-    </variablelist>
-   </para>
-  </refsect2>
 
-  <refsect2 id="R2-APP-PGCTL-2">
-   <refsect2info>
-    <date>1999-11-07</date>
-   </refsect2info>
-   <title>
-    Outputs
-   </title>
-   <para>
-    <variablelist>
      <varlistentry>
-      <term><computeroutput>pg_ctl: postmaster is <replaceable>state</replaceable> (pid: <replaceable>#</replaceable>)</computeroutput></term>
+      <term><option>-W</option></term>
       <listitem>
        <para>
-       Postmaster status.
+        Do not wait for startup or shutdown to complete.  This is the
+        default for start and restart modes.
        </para>
       </listitem>
      </varlistentry>
-    </variablelist>
-
-    If there is an error condition, the backend error message will be displayed.
-   </para>
-  </refsect2>
- </refsynopsisdiv>
-
- <refsect1 id="R1-APP-PGCTL-1">
-  <title>
-   Description
-  </title>
-  <para>
-   <application>pg_ctl</application> is a utility for starting,
-   stopping or restarting <application>postmaster</application>.
-  </para>
- </refsect1>
-
- <refsect1 id="R1-APP-PGCTL-2">
-  <title>
-   Usage
-  </title>
-
-  <refsect2 id="R2-APP-PGCTL-3">
-   <title>
-    Starting postmaster
-   </title>
 
-   <para>
-    To start up <application>postmaster</application>:
+     <varlistentry>
+      <term><option>-?</></term>
+      <term><option>--help</></term>
+      <listitem>
+       <para>
+        Show help about <application>pg_ctl</application> command line
+        arguments, and exit.
+       </para>
+      </listitem>
+     </varlistentry>
+   </variablelist>
 
-    <programlisting>
-$ pg_ctl start
-    </programlisting>
-   </para>
+  <refsect2 id="app-pg-ctl-windows-options">
+   <title>Options for Windows</title>
 
-   <para>
-    If -w is supplied, pg_ctl waits for the database server to come up, by
-    watching for creation of the pid file (PGDATA/postmaster.pid), for up
-    to 60 seconds.
-   </para>
+   <variablelist>
+    <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
+       the logging from <application>pg_ctl</application> itself - once
+       started, the server will use the event source specified
+       by <xref linkend="guc-event-source">.  Should the server fail during
+       early startup, it may also log using the default event
+       source <literal>PostgreSQL</literal>.
+      </para>
+     </listitem>
+    </varlistentry>
 
-   <para>
-    Parameters to invoke <application>postmaster</application> are
-    taken from the following sources:
+    <varlistentry>
+     <term><option>-N <replaceable class="parameter">servicename</replaceable></option></term>
+     <listitem>
+      <para>
+       Name of the system service to register. The name will be used
+       as both the service name and the display name.
+      </para>
+     </listitem>
+    </varlistentry>
 
-    <itemizedlist>
+    <varlistentry>
+     <term><option>-P <replaceable class="parameter">password</replaceable></option></term>
      <listitem>
       <para>
-       Path to postmaster: found in the command search path.
+       Password for the user to start the service.
       </para>
      </listitem>
+    </varlistentry>
 
+    <varlistentry>
+     <term><option>-S <replaceable class="parameter">start-type</replaceable></option></term>
      <listitem>
       <para>
-       Database directory: <envar>PGDATA</envar> environment variable.
+       Start type of the system service to register.  start-type can
+       be <literal>auto</literal>, or <literal>demand</literal>, or
+       the first letter of one of these two. If this is omitted,
+       <literal>auto</literal> is used.
       </para>
      </listitem>
+    </varlistentry>
 
+    <varlistentry>
+     <term><option>-U <replaceable class="parameter">username</replaceable></option></term>
      <listitem>
       <para>
-       Other parameters:
-       <filename><envar>PGDATA</envar>/postmaster.opts.default</filename>.
+       User name for the user to start the service. For domain users, use the
+       format <literal>DOMAIN\username</literal>.
       </para>
      </listitem>
-    </itemizedlist>
-   </para>
+    </varlistentry>
+   </variablelist>
+  </refsect2>
 
-   <para>
-    <filename>postmaster.opts.default</filename> contains parameters
-    for <application>postmaster</application>.
-   </para>
+ </refsect1>
 
-   <para>
-    Note that <filename>postmaster.opts.default</filename> is
-    installed by <application>initdb</application> from
-    <filename>lib/postmaster.opts.default.sample</filename>
-    under the <productname>Postgres</productname> installation
-    directory (<filename>lib/postmaster.opts.default.sample</filename>
-    is copied from
-    <filename>src/bin/pg_ctl/postmaster.opts.default.sample</filename>
-    while installing <productname>Postgres</productname>).
-   </para>
 
-   <para>
-    To override the default parameters you can use <option>-D</option>,
-    <option>-p</option> and <option>-o</option> options.
-   </para>
+ <refsect1>
+  <title>Environment</title>
+
+  <variablelist>
+   <varlistentry>
+    <term><envar>PGDATA</envar></term>
+
+    <listitem>
+     <para>
+      Default data directory location.
+     </para>
+    </listitem>
+   </varlistentry>
+
+  </variablelist>
+
+  <para>
+   <command>pg_ctl</command>, like most other <productname>PostgreSQL</>
+   utilities,
+   also uses the environment variables supported by <application>libpq</>
+   (see <xref linkend="libpq-envars">).
+   For additional server variables, see <xref linkend="app-postgres">.
+  </para>
+ </refsect1>
+
+
+ <refsect1>
+  <title>Files</title>
+
+  <variablelist>
+   <varlistentry>
+    <term><filename>postmaster.pid</filename></term>
+
+    <listitem>
+     <para>
+      The existence of this file in the data directory is used to help
+      <application>pg_ctl</application> determine if the server is
+      currently running.
+     </para>
+    </listitem>
+   </varlistentry>
+
+   <varlistentry>
+    <term><filename>postmaster.opts</filename></term>
+
+    <listitem>
+     <para>If this file exists in the data directory,
+      <application>pg_ctl</application> (in <option>restart</option> mode)
+      will pass the contents of the file as options to
+      <application>postgres</application>, unless overridden
+      by the <option>-o</option> option. The contents of this file
+      are also displayed in <option>status</option> mode.
+     </para>
+    </listitem>
+   </varlistentry>
+
+  </variablelist>
+ </refsect1>
+
+
+ <refsect1 id="R1-APP-PGCTL-2">
+  <title>Examples</title>
+
+  <refsect2 id="R2-APP-PGCTL-3">
+   <title>Starting the Server</title>
 
    <para>
-    An example of starting the
-    <application>postmaster</application>, blocking until
-    postmaster comes up is:
-    <programlisting>
-$ pg_ctl -w start
-    </programlisting>
+    To start the server:
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl start</userinput>
+</screen>
    </para>
 
    <para>
-    To specify the <application>postmaster</application> binary path,
-    try:
-
-    <programlisting>
-$ pg_ctl -p /usr/local/pgsq/bin/postmaster start
-    </programlisting>
+    To start the server, waiting until the server is
+    accepting connections:
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl -w start</userinput>
+</screen>
    </para>
 
    <para>
-    For a <application>postmaster</application> using port 5433, and
+    To start the server using port 5433, and
     running without <function>fsync</function>, use:
-
-    <programlisting>
-$ pg_ctl -o "-o -F -p 5433" start
-    </programlisting>
-   </para>
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" start</userinput>
+</screen></para>
   </refsect2>
 
   <refsect2 id="R2-APP-PGCTL-4">
-   <title>
-    Stopping postmaster
-   </title>
+   <title>Stopping the Server</title>
    <para>
-
-    <programlisting>
-$ pg_ctl stop
-    </programlisting>
-
-    stops postmaster. Using the <option>-m</option> switch allows one
-    to control <emphasis>how</emphasis> the backend shuts down.
-    <option>-w</option>
-    waits for postmaster to shut down.
-    <option>-m</option> specifies the shut down mode.
-   </para>
+    To stop the server, use:
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl stop</userinput>
+</screen>
+    The <option>-m</option> option allows control over
+    <emphasis>how</emphasis> the server shuts down:
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl stop -m fast</userinput>
+</screen></para>
   </refsect2>
 
   <refsect2 id="R2-APP-PGCTL-5">
-   <title>
-    Restarting postmaster
-   </title>
+   <title>Restarting the Server</title>
 
    <para>
-    This is almost equivalent to stopping the
-    <application>postmaster</application> then starting it
-    again except that the parameters used before stopping
-    it would be used too. This is done by saving them in
-    $<envar>PGDATA</envar>/postmaster.opts file.
-    <option>-w</option>, <option>-D</option>, <option>-m</option>,
-    <option>-fast</option>, <option>-immediate</option> and
-    <option>-o</option> 
-    can also be used in the restarting mode and they have the same meanings as
-    described above.
+    Restarting the server is almost equivalent to stopping the
+    server and starting it again,
+    except that <command>pg_ctl</command> saves and reuses the command line options that
+    were passed to the previously running instance.  To restart
+    the server in the simplest form, use:
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl restart</userinput>
+</screen>
    </para>
 
    <para>
-    To restart <application>postmaster</application> in the simplest
-    form:
-
-    <programlisting>
-$ pg_ctl restart
-    </programlisting>
+    To restart the server,
+    waiting for it to shut down and restart:
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl -w restart</userinput>
+</screen>
    </para>
 
    <para>
-    To restart <application>postmaster</application>,
-    waiting for it to shut down and to come up:
+    To restart using port 5433, disabling <function>fsync</> upon restart:
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" restart</userinput>
+</screen></para>
+  </refsect2>
 
-    <programlisting>
-$ pg_ctl -w restart
-    </programlisting>
-   </para>
+  <refsect2 id="R2-APP-PGCTL-6">
+   <title>Showing the Server Status</title>
 
    <para>
-    To restart using port 5433 and disabling fsync after restarting:
-
-    <programlisting>
-$ pg_ctl -o "-o -F -p 5433" restart
-    </programlisting>
+    Here is sample status output from
+    <application>pg_ctl</application>:
+<screen>
+<prompt>$</prompt> <userinput>pg_ctl status</userinput>
+<computeroutput>
+pg_ctl: server is running (PID: 13718)
+/usr/local/pgsql/bin/postgres "-D" "/usr/local/pgsql/data" "-p" "5433" "-B" "128"
+</computeroutput>
+</screen>
+    This is the command line that would be invoked in restart mode.
    </para>
   </refsect2>
+ </refsect1>
 
-  <refsect2 id="R2-APP-PGCTL-6">
-   <title>
-    postmaster status
-   </title>
 
  <para>
-    To get status information from postmaster:
<refsect1>
+  <title>See Also</title>
 
-    <programlisting>
-$ pg_ctl status
-    </programlisting>
-   </para>
-
-   <para>
-    Here is a sample output from <application>pg_ctl</application>:
-
-    <programlisting>
-pg_ctl: postmaster is running (pid: 13718)
-options are:
-/usr/local/src/pgsql/current/bin/postmaster
--p 5433
--D /usr/local/src/pgsql/current/data
--B 64
--b /usr/local/src/pgsql/current/bin/postgres
--N 32
--o '-F'
-    </programlisting>
-   </para>
-  </refsect2>
+  <simplelist type="inline">
+   <member><xref linkend="app-initdb"></member>
+   <member><xref linkend="app-postgres"></member>
+  </simplelist>
  </refsect1>
-</refentry>
 
-<!-- Keep this comment at the end of the file
-Local variables:
-mode:sgml
-sgml-omittag:nil
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:1
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:"../reference.ced"
-sgml-exposed-tags:nil
-sgml-local-catalogs:("/usr/lib/sgml/catalog")
-sgml-local-ecat-files:nil
-End:
--->
+</refentry>