2 $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_ctl-ref.sgml,v 1.2 2000/10/08 13:22:24 petere Exp $
6 <refentry id="app-pg-ctl">
8 <refentrytitle id="app-pg-ctl-title">
9 <application>pg_ctl</application>
11 <refmiscinfo>Application</refmiscinfo>
16 <application>pg_ctl</application>
19 Starts, stops, and restarts postmaster
25 <date>2000-04-05</date>
29 pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>][-p <replaceable class="parameter">path</replaceable>] [-o "<replaceable class="parameter">options</replaceable>"] start
30 pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>] [-m [s[mart]|f[ast]|i[mmediate]]] stop
31 pg_ctl [-w] [-D <replaceable class="parameter">datadir</replaceable>] [-m [s[mart]|f[ast]|i[mmediate]]
32 [-o "<replaceable class="parameter">options</replaceable>"] restart
33 pg_ctl [-D <replaceable class="parameter">datadir</replaceable>] status
36 <refsect2 id="R2-APP-PGCTL-1">
47 Wait for the database server to come up, by
48 watching for creation of the pid file (PGDATA/postmaster.pid).
49 Times out after 60 seconds.
55 <term>-D <replaceable class="parameter">datadir</replaceable></term>
58 Specifies the database location for this database installation.
64 <term>-p <replaceable class="parameter">path</replaceable></term>
67 Specifies the path to the postmaster image.
73 <term>-o "<replaceable class="parameter">options</replaceable>"</term>
76 Specifies options to be passed directly to
77 <application>postmaster</application>.
80 The parameters are usually surrounded by single or double
81 quotes to ensure that they are passed through as a group.
87 <term>-m <replaceable class="parameter">mode</replaceable></term>
90 Specifies the shutdown mode.
98 smart mode waits for all
99 the clients to logout. This is the default.
109 Fast mode sends SIGTERM to the backends; that means
110 active transactions get rolled back.
116 <term>immediate</term>
120 Immediate mode sends SIGUSR1
121 to the backends and lets them abort. In this case, database recovery
122 will be necessary on the next start-up.
135 Start up <application>postmaster</application>.
144 Shut down <application>postmaster</application>.
153 Restart the <application>postmaster</application>, performing
154 a stop/start sequence.
163 Show the current state of <application>postmaster</application>.
171 <refsect2 id="R2-APP-PGCTL-2">
173 <date>1999-11-07</date>
181 <term><computeroutput>pg_ctl: postmaster is <replaceable>state</replaceable> (pid: <replaceable>#</replaceable>)</computeroutput></term>
190 If there is an error condition, the backend error message will be displayed.
195 <refsect1 id="R1-APP-PGCTL-1">
200 <application>pg_ctl</application> is a utility for starting,
201 stopping or restarting <application>postmaster</application>.
205 <refsect1 id="R1-APP-PGCTL-2">
210 <refsect2 id="R2-APP-PGCTL-3">
216 To start up <application>postmaster</application>:
224 If -w is supplied, pg_ctl waits for the database server to come up, by
225 watching for creation of the pid file (PGDATA/postmaster.pid), for up
230 Parameters to invoke <application>postmaster</application> are
231 taken from the following sources:
236 Path to postmaster: found in the command search path.
242 Database directory: <envar>PGDATA</envar> environment variable.
249 <filename><envar>PGDATA</envar>/postmaster.opts.default</filename>.
256 <filename>postmaster.opts.default</filename> contains parameters
257 for <application>postmaster</application>.
261 Note that <filename>postmaster.opts.default</filename> is
262 installed by <application>initdb</application> from
263 <filename>lib/postmaster.opts.default.sample</filename>
264 under the <productname>Postgres</productname> installation
265 directory (<filename>lib/postmaster.opts.default.sample</filename>
267 <filename>src/bin/pg_ctl/postmaster.opts.default.sample</filename>
268 while installing <productname>Postgres</productname>).
272 To override the default parameters you can use <option>-D</option>,
273 <option>-p</option> and <option>-o</option> options.
277 An example of starting the
278 <application>postmaster</application>, blocking until
279 postmaster comes up is:
286 To specify the <application>postmaster</application> binary path,
290 $ pg_ctl -p /usr/local/pgsq/bin/postmaster start
295 For a <application>postmaster</application> using port 5433, and
296 running without <function>fsync</function>, use:
299 $ pg_ctl -o "-o -F -p 5433" start
304 <refsect2 id="R2-APP-PGCTL-4">
314 stops postmaster. Using the <option>-m</option> switch allows one
315 to control <emphasis>how</emphasis> the backend shuts down.
317 waits for postmaster to shut down.
318 <option>-m</option> specifies the shut down mode.
322 <refsect2 id="R2-APP-PGCTL-5">
324 Restarting postmaster
328 This is almost equivalent to stopping the
329 <application>postmaster</application> then starting it
330 again except that the parameters used before stopping
331 it would be used too. This is done by saving them in
332 $<envar>PGDATA</envar>/postmaster.opts file.
333 <option>-w</option>, <option>-D</option>, <option>-m</option>,
334 <option>-fast</option>, <option>-immediate</option> and
336 can also be used in the restarting mode and they have the same meanings as
341 To restart <application>postmaster</application> in the simplest
350 To restart <application>postmaster</application>,
351 waiting for it to shut down and to come up:
359 To restart using port 5433 and disabling fsync after restarting:
362 $ pg_ctl -o "-o -F -p 5433" restart
367 <refsect2 id="R2-APP-PGCTL-6">
373 To get status information from postmaster:
381 Here is a sample output from <application>pg_ctl</application>:
384 pg_ctl: postmaster is running (pid: 13718)
386 /usr/local/src/pgsql/current/bin/postmaster
388 -D /usr/local/src/pgsql/current/data
390 -b /usr/local/src/pgsql/current/bin/postgres
399 <!-- Keep this comment at the end of the file
404 sgml-minimize-attributes:nil
405 sgml-always-quote-attributes:t
408 sgml-parent-document:nil
409 sgml-default-dtd-file:"../reference.ced"
410 sgml-exposed-tags:nil
411 sgml-local-catalogs:("/usr/lib/sgml/catalog")
412 sgml-local-ecat-files:nil