2 $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_ctl-ref.sgml,v 1.4 2000/11/25 17:17:30 petere Exp $
6 <refentry id="app-pg-ctl">
8 <date>2000-11-25</date>
12 <refentrytitle id="app-pg-ctl-title"><application>pg_ctl</application></refentrytitle>
13 <manvolnum>1</manvolnum>
14 <refmiscinfo>Application</refmiscinfo>
18 <refname>pg_ctl</refname>
19 <refpurpose>Starts, stops, or restarts postmaster</refpurpose>
24 <command>pg_ctl</command>
25 <arg choice="plain">start</arg>
27 <arg>-D <replaceable>datadir</replaceable></arg>
28 <arg>-p <replaceable>path</replaceable></arg>
29 <arg>-o <replaceable>options</replaceable></arg>
31 <command>pg_ctl</command>
32 <arg choice="plain">stop</arg>
34 <arg>-D <replaceable>datadir</replaceable></arg>
36 <group choice="plain">
39 <arg>i[mmediate]</arg>
43 <command>pg_ctl</command>
44 <arg choice="plain">restart</arg>
46 <arg>-D <replaceable>datadir</replaceable></arg>
48 <group choice="plain">
51 <arg>i[mmediate]</arg>
54 <arg>-o <replaceable>options</replaceable></arg>
56 <command>pg_ctl</command>
57 <arg choice="plain">status</arg>
58 <arg>-D <replaceable>datadir</replaceable></arg>
63 <refsect1 id="app-pg-ctl-description">
64 <title>Description</title>
66 <application>pg_ctl</application> is a utility for starting,
67 stopping, or restarting the <xref linkend="app-postmaster"
68 endterm="app-postmaster-title">, or displaying the status of a
72 <refsect2 id="app-pg-ctl-options">
73 <title>Options</title>
81 Wait for the database server to come up, by watching for
82 creation of the pid file
83 (<filename><replaceable>PGDATA</replaceable>/postmaster.pid</filename>).
84 Times out after 60 seconds.
90 <term>-D <replaceable class="parameter">datadir</replaceable></term>
93 Specifies the file system location of the database files. If
94 this is omitted, the environment variable
95 <envar>PGDATA</envar> is used.
101 <term>-p <replaceable class="parameter">path</replaceable></term>
104 Specifies the location of the <filename>postmaster</filename>
105 executable. By default the postmaster is taken from the same
106 directory as pg_ctl, or failing that, the hard-wired
107 installation directory. It is not necessary to use this
108 option unless you are doing something unusual and get errors
109 that the postmaster was not found.
115 <term>-o <replaceable class="parameter">options</replaceable></term>
118 Specifies options to be passed directly to
119 <application>postmaster</application>.
122 The parameters are usually surrounded by single or double
123 quotes to ensure that they are passed through as a group.
129 <term>-m <replaceable class="parameter">mode</replaceable></term>
132 Specifies the shutdown mode.
140 Smart mode waits for all the clients to disconnect. This
151 Fast mode does not wait for clients to disconnect. All
152 active transactions will be rolled back.
158 <term>immediate</term>
162 Immediate mode will abort without complete shutdown. This
163 will lead to a recovery run on restart.
176 Start up <application>postmaster</application>.
185 Shut down <application>postmaster</application>.
194 Stop the <application>postmaster</application>, if one is running,
195 and then start it again.
204 Show the current state of <application>postmaster</application>.
216 If the file <filename>postmaster.opts.default</filename> exists in
217 the data directory, the contents of the file will be passed as
218 options to the <application>postmaster</application>, unless
219 overridden by the <option>-o</option> option.
226 <refsect1 id="R1-APP-PGCTL-2">
229 <refsect2 id="R2-APP-PGCTL-3">
230 <title>Starting the postmaster</title>
233 To start up <application>postmaster</application>:
235 <prompt>$</prompt> <userinput>pg_ctl start</userinput>
240 An example of starting the <application>postmaster</application>,
241 blocking until postmaster comes up is:
243 <prompt>$</prompt> <userinput>pg_ctl -w start</userinput>
248 For a <application>postmaster</application> using port 5433, and
249 running without <function>fsync</function>, use:
251 <prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" start</userinput>
256 <refsect2 id="R2-APP-PGCTL-4">
257 <title>Stopping the postmaster</title>
260 <prompt>$</prompt> <userinput>pg_ctl stop</userinput>
262 stops postmaster. Using the <option>-m</option> switch allows one
263 to control <emphasis>how</emphasis> the backend shuts down.
264 <option>-w</option> waits for postmaster to shut down.
268 <refsect2 id="R2-APP-PGCTL-5">
269 <title>Restarting the postmaster</title>
272 This is almost equivalent to stopping the
273 <application>postmaster</application> then starting it again
274 except that pg_ctl saves and reuses the command line options that
275 were passed to the previously running instance. To restart
276 <application>postmaster</application> in the simplest form:
278 <prompt>$</prompt> <userinput>pg_ctl restart</userinput>
283 To restart <application>postmaster</application>,
284 waiting for it to shut down and to come up:
286 <prompt>$</prompt> <userinput>pg_ctl -w restart</userinput>
291 To restart using port 5433 and disabling fsync after restarting:
293 <prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" restart</userinput>
298 <refsect2 id="R2-APP-PGCTL-6">
299 <title>Showing postmaster status</title>
302 Here is a sample status output from
303 <application>pg_ctl</application>:
305 <prompt>$</prompt> <userinput>pg_ctl status</userinput>
307 pg_ctl: postmaster is running (pid: 13718)
309 /usr/local/pgsql/bin/postmaster '-D' '/usr/local/pgsql/data' '-p' '5433' '-B' '128'
312 This is the command line that would be invoked in restart mode.
318 <!-- Keep this comment at the end of the file
323 sgml-minimize-attributes:nil
324 sgml-always-quote-attributes:t
327 sgml-parent-document:nil
328 sgml-default-dtd-file:"../reference.ced"
329 sgml-exposed-tags:nil
330 sgml-local-catalogs:("/usr/lib/sgml/catalog")
331 sgml-local-ecat-files:nil