Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/pg_ctl-ref.sgml`
eef7c5ea2a1c8e00408253ae789be4a5328a725e2f198d2d0000000100000fa4
 choice="plain"><option>reload</option></arg>
   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></arg>
   <arg choice="opt"><option>-s</option></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>-D</option> <replaceable>datadir</replaceable></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>
  </cmdsynopsis>

  <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>

  <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>

  <para>On Microsoft Windows, also:</para>

  <cmdsynopsis>
   <command>pg_ctl</command>
   <arg choice="plain"><option>register</option></arg>
   <arg choice="opt"><option>-D</option> <replaceable>datadir</replaceable></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>-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>-e</option> <replaceable>source</replaceable></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, that is,
   a collection of databases that will be managed by a single
   server instance.  This mode invokes the <command>initdb</command>
   command.  See <xref linkend="app-initdb"/> for details.
  </para>

  <para>
   <option>start</option> mode launches a new server.  The
   server is started in the background, and its standard input is attached
   to <filename>/dev/null</filename> (or <literal>nul</literal> 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>

Title: pg_ctl Command Syntax and Description
Summary
This section details the syntax for various `pg_ctl` commands including `reload`, `status`, `promote`, `logrotate`, and `kill`. It also includes Windows-specific commands for registering and unregistering PostgreSQL as a service. The description clarifies that `pg_ctl` initializes database clusters, starts, stops, restarts, and displays the status of PostgreSQL servers, managing tasks like log redirection and shutdown procedures, acting as a wrapper around commands like `initdb`.