2 $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_ctl-ref.sgml,v 1.5 2000/12/25 23:15:26 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">, or
68 displaying the status of a running postmaster.
71 <refsect2 id="app-pg-ctl-options">
72 <title>Options</title>
80 Wait for the database server to come up, by watching for
81 creation of the pid file
82 (<filename><replaceable>PGDATA</replaceable>/postmaster.pid</filename>).
83 Times out after 60 seconds.
89 <term>-D <replaceable class="parameter">datadir</replaceable></term>
92 Specifies the file system location of the database files. If
93 this is omitted, the environment variable
94 <envar>PGDATA</envar> is used.
100 <term>-p <replaceable class="parameter">path</replaceable></term>
103 Specifies the location of the <filename>postmaster</filename>
104 executable. By default the postmaster is taken from the same
105 directory as pg_ctl, or failing that, the hard-wired
106 installation directory. It is not necessary to use this
107 option unless you are doing something unusual and get errors
108 that the postmaster was not found.
114 <term>-o <replaceable class="parameter">options</replaceable></term>
117 Specifies options to be passed directly to
118 <application>postmaster</application>.
121 The parameters are usually surrounded by single or double
122 quotes to ensure that they are passed through as a group.
128 <term>-m <replaceable class="parameter">mode</replaceable></term>
131 Specifies the shutdown mode.
139 Smart mode waits for all the clients to disconnect. This
150 Fast mode does not wait for clients to disconnect. All
151 active transactions will be rolled back.
157 <term>immediate</term>
161 Immediate mode will abort without complete shutdown. This
162 will lead to a recovery run on restart.
175 Start up <application>postmaster</application>.
184 Shut down <application>postmaster</application>.
193 Stop the <application>postmaster</application>, if one is running,
194 and then start it again.
203 Show the current state of <application>postmaster</application>.
215 If the file <filename>postmaster.opts.default</filename> exists in
216 the data directory, the contents of the file will be passed as
217 options to the <application>postmaster</application>, unless
218 overridden by the <option>-o</option> option.
225 <refsect1 id="R1-APP-PGCTL-2">
228 <refsect2 id="R2-APP-PGCTL-3">
229 <title>Starting the postmaster</title>
232 To start up <application>postmaster</application>:
234 <prompt>$</prompt> <userinput>pg_ctl start</userinput>
239 An example of starting the <application>postmaster</application>,
240 blocking until postmaster comes up is:
242 <prompt>$</prompt> <userinput>pg_ctl -w start</userinput>
247 For a <application>postmaster</application> using port 5433, and
248 running without <function>fsync</function>, use:
250 <prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" start</userinput>
255 <refsect2 id="R2-APP-PGCTL-4">
256 <title>Stopping the postmaster</title>
259 <prompt>$</prompt> <userinput>pg_ctl stop</userinput>
261 stops postmaster. Using the <option>-m</option> switch allows one
262 to control <emphasis>how</emphasis> the backend shuts down.
263 <option>-w</option> waits for postmaster to shut down.
267 <refsect2 id="R2-APP-PGCTL-5">
268 <title>Restarting the postmaster</title>
271 This is almost equivalent to stopping the
272 <application>postmaster</application> then starting it again
273 except that pg_ctl saves and reuses the command line options that
274 were passed to the previously running instance. To restart
275 <application>postmaster</application> in the simplest form:
277 <prompt>$</prompt> <userinput>pg_ctl restart</userinput>
282 To restart <application>postmaster</application>,
283 waiting for it to shut down and to come up:
285 <prompt>$</prompt> <userinput>pg_ctl -w restart</userinput>
290 To restart using port 5433 and disabling fsync after restarting:
292 <prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" restart</userinput>
297 <refsect2 id="R2-APP-PGCTL-6">
298 <title>Showing postmaster status</title>
301 Here is a sample status output from
302 <application>pg_ctl</application>:
304 <prompt>$</prompt> <userinput>pg_ctl status</userinput>
306 pg_ctl: postmaster is running (pid: 13718)
308 /usr/local/pgsql/bin/postmaster '-D' '/usr/local/pgsql/data' '-p' '5433' '-B' '128'
311 This is the command line that would be invoked in restart mode.
317 <!-- Keep this comment at the end of the file
322 sgml-minimize-attributes:nil
323 sgml-always-quote-attributes:t
326 sgml-parent-document:nil
327 sgml-default-dtd-file:"../reference.ced"
328 sgml-exposed-tags:nil
329 sgml-local-catalogs:("/usr/lib/sgml/catalog")
330 sgml-local-ecat-files:nil