]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/pg_ctl-ref.sgml
A small patch for a small option (for rel. 7.1).
[postgresql] / doc / src / sgml / ref / pg_ctl-ref.sgml
1 <!--
2 $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_ctl-ref.sgml,v 1.7 2001/04/27 01:31:56 momjian Exp $
3 Postgres documentation
4 -->
5
6 <refentry id="app-pg-ctl">
7  <docinfo>
8   <date>2001-02-08</date>
9  </docinfo>
10
11  <refmeta>
12   <refentrytitle id="app-pg-ctl-title"><application>pg_ctl</application></refentrytitle>
13   <manvolnum>1</manvolnum>
14   <refmiscinfo>Application</refmiscinfo>
15  </refmeta>
16
17  <refnamediv>
18   <refname>pg_ctl</refname>
19   <refpurpose>Starts, stops, or restarts postmaster</refpurpose>
20  </refnamediv>
21
22  <refsynopsisdiv>
23   <cmdsynopsis>
24    <command>pg_ctl</command>
25    <arg choice="plain">start</arg>
26    <arg>-w</arg>
27    <arg>-s</arg>
28    <arg>-D <replaceable>datadir</replaceable></arg>
29    <arg>-l <replaceable>filename</replaceable></arg>
30    <arg>-o <replaceable>options</replaceable></arg>
31    <arg>-p <replaceable>path</replaceable></arg>
32    <sbr>
33    <command>pg_ctl</command>
34    <arg choice="plain">stop</arg>
35    <arg>-W</arg>
36    <arg>-s</arg>
37    <arg>-D <replaceable>datadir</replaceable></arg>
38    <arg>-m
39      <group choice="plain">
40        <arg>s[mart]</arg>
41        <arg>f[ast]</arg>
42        <arg>i[mmediate]</arg>
43      </group>
44    </arg>
45    <sbr>
46    <command>pg_ctl</command>
47    <arg choice="plain">restart</arg>
48    <arg>-w</arg>
49    <arg>-s</arg>
50    <arg>-D <replaceable>datadir</replaceable></arg>
51    <arg>-m
52      <group choice="plain">
53        <arg>s[mart]</arg>
54        <arg>f[ast]</arg>
55        <arg>i[mmediate]</arg>
56      </group>
57    </arg>
58    <arg>-o <replaceable>options</replaceable></arg>
59    <sbr>
60    <command>pg_ctl</command>
61    <arg choice="plain">status</arg>
62    <arg>-D <replaceable>datadir</replaceable></arg>
63   </cmdsynopsis>
64  </refsynopsisdiv>
65
66
67  <refsect1 id="app-pg-ctl-description">
68   <title>Description</title>
69   <para>
70    <application>pg_ctl</application> is a utility for starting,
71    stopping, or restarting <xref linkend="app-postmaster">, the
72    <productname>PostgreSQL</productname> backend server, or displaying
73    the status of a running postmaster.  Although the postmaster can be
74    started manually, <application>pg_ctl</application> encapulates
75    tasks such as redirecting log output, properly detaching from the
76    terminal and process group, and additionally provides an option for
77    controlled shut down.
78   </para>
79
80   <para>
81    In <option>start</option> mode, a new postmaster is launched.  The
82    server is started in the background, the standard input attached to
83    <filename>/dev/null</filename>.  The standard output and standard
84    error are either appended to a log file, if the <option>-l</option>
85    option is used, or are redirected to
86    <application>pg_ctl</application>'s standard output (not standard
87    error).  If no log file is chosen, the standard output of
88    <application>pg_ctl</application> should be redirected to a file or
89    piped to another process, for example a log rotating program,
90    otherwise the postmaster will write its output the the controlling
91    terminal (from the background) and will not leave the shell's
92    process group.
93   </para>
94
95   <para>
96    In <option>stop</option> mode, the postmaster that is running on
97    the specified data directory is shut down.  Three different
98    shutdown methods can be selected with the <option>-m</option>
99    option: <quote>Smart</quote> mode waits for all the clients to
100    disconnect.  This is the default.  <quote>Fast</quote> mode does
101    not wait for clients to disconnect.  All active transactions will
102    be rolled back.  <quote>Immediate</quote> mode will abort without
103    complete shutdown.  This will lead to a recovery run on restart.
104    By the default, stop mode waits for the shutdown to complete.
105   </para>
106
107   <para>
108    <option>restart</option> mode effectively executes a stop followed
109    by a start.  This allows the changing of postmaster command line
110    options.
111   </para>
112
113   <para>
114    <option>status</option> mode checks whether a postmaster is running
115    and if so displays the <acronym>PID</acronym> and the command line
116    options that were used to invoke it.
117   </para>
118
119   <refsect2 id="app-pg-ctl-options">
120    <title>Options</title>
121    <para>
122
123     <variablelist>
124      <varlistentry>
125       <term>-D <replaceable class="parameter">datadir</replaceable></term>
126       <listitem>
127        <para>
128         Specifies the file system location of the database files.  If
129         this is omitted, the environment variable
130         <envar>PGDATA</envar> is used.
131        </para>
132       </listitem>
133      </varlistentry>
134
135      <varlistentry>
136       <term>-l <replaceable class="parameter">filename</replaceable></term>
137       <listitem>
138        <para>
139         Append the server log output to
140         <replaceable>filename</replaceable>.  If the file does not
141         exist, it is created.  The umask is set to 077, so access to
142         the log file from other users is disallowed by default.
143        </para>
144       </listitem>
145      </varlistentry>
146
147      <varlistentry>
148       <term>-m <replaceable class="parameter">mode</replaceable></term>
149       <listitem>
150        <para>
151         Specifies the shutdown mode.  <replaceable>mode</replaceable>
152         may be <literal>smart</literal>, <literal>fast</literal>, or
153         <literal>immediate</literal>, or the first letter of one of
154         these three.
155        </para>
156       </listitem>
157      </varlistentry>
158
159      <varlistentry>
160       <term>-o <replaceable class="parameter">options</replaceable></term>
161       <listitem>
162        <para>
163         Specifies options to be passed directly to
164         <application>postmaster</application>.
165        </para>
166        <para>
167         The parameters are usually surrounded by single or double
168         quotes to ensure that they are passed through as a group.
169        </para>
170       </listitem>
171      </varlistentry>
172
173      <varlistentry>
174       <term>-p <replaceable class="parameter">path</replaceable></term>
175       <listitem>
176        <para>
177         Specifies the location of the <filename>postmaster</filename>
178         executable.  By default the postmaster is taken from the same
179         directory as pg_ctl, or failing that, the hard-wired
180         installation directory.  It is not necessary to use this
181         option unless you are doing something unusual and get errors
182         that the postmaster was not found.
183        </para>
184       </listitem>
185      </varlistentry>
186
187      <varlistentry>
188       <term>-w</term>
189       <listitem>
190        <para>
191         Wait for the start or stutdown to complete.  Times out after
192         60 seconds.  This is the default for shutdowns.
193        </para>
194       </listitem>
195      </varlistentry>
196
197      <varlistentry>
198       <term>-W</term>
199       <listitem>
200        <para>
201         Do not wait for start or shutdown to complete.  This is the
202         default for starts and restarts.
203        </para>
204       </listitem>
205      </varlistentry>
206
207      <varlistentry>
208       <term>-s</term>
209       <listitem>
210        <para>
211         Only print errors, no informational messages.
212        </para>
213       </listitem>
214      </varlistentry>
215     </variablelist>
216    </para>
217   </refsect2>
218
219   <refsect2>
220    <title>Files</title>
221
222    <para>
223     If the file <filename>postmaster.opts.default</filename> exists in
224     the data directory, the contents of the file will be passed as
225     options to the <application>postmaster</application>, unless
226     overridden by the <option>-o</option> option.
227    </para>
228   </refsect2>
229
230  </refsect1>
231
232
233  <refsect1 id="R1-APP-PGCTL-2">
234   <title>Examples</title>
235
236   <refsect2 id="R2-APP-PGCTL-3">
237    <title>Starting the postmaster</title>
238
239    <para>
240     To start up <application>postmaster</application>:
241 <screen>
242 <prompt>$</prompt> <userinput>pg_ctl start</userinput>
243 </screen>
244    </para>
245
246    <para>
247     An example of starting the <application>postmaster</application>,
248     blocking until postmaster comes up is:
249 <screen>
250 <prompt>$</prompt> <userinput>pg_ctl -w start</userinput>
251 </screen>
252    </para>
253
254    <para>
255     For a <application>postmaster</application> using port 5433, and
256     running without <function>fsync</function>, use:
257 <screen>
258 <prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" start</userinput>
259 </screen>
260    </para>
261   </refsect2>
262
263   <refsect2 id="R2-APP-PGCTL-4">
264    <title>Stopping the postmaster</title>
265    <para>
266 <screen>
267 <prompt>$</prompt> <userinput>pg_ctl stop</userinput>
268 </screen>
269     stops postmaster. Using the <option>-m</option> switch allows one
270     to control <emphasis>how</emphasis> the backend shuts down.
271    </para>
272   </refsect2>
273
274   <refsect2 id="R2-APP-PGCTL-5">
275    <title>Restarting the postmaster</title>
276
277    <para>
278     This is almost equivalent to stopping the
279     <application>postmaster</application> then starting it again
280     except that pg_ctl saves and reuses the command line options that
281     were passed to the previously running instance.  To restart
282     <application>postmaster</application> in the simplest form:
283 <screen>
284 <prompt>$</prompt> <userinput>pg_ctl restart</userinput>
285 </screen>
286    </para>
287
288    <para>
289     To restart <application>postmaster</application>,
290     waiting for it to shut down and to come up:
291 <screen>
292 <prompt>$</prompt> <userinput>pg_ctl -w restart</userinput>
293 </screen>
294    </para>
295
296    <para>
297     To restart using port 5433 and disabling fsync after restarting:
298 <screen>
299 <prompt>$</prompt> <userinput>pg_ctl -o "-F -p 5433" restart</userinput>
300 </screen>
301    </para>
302   </refsect2>
303
304   <refsect2 id="R2-APP-PGCTL-6">
305    <title>Showing postmaster status</title>
306
307    <para>
308     Here is a sample status output from
309     <application>pg_ctl</application>:
310 <screen>
311 <prompt>$</prompt> <userinput>pg_ctl status</userinput>
312 <computeroutput>
313 pg_ctl: postmaster is running (pid: 13718)
314 Command line was:
315 /usr/local/pgsql/bin/postmaster '-D' '/usr/local/pgsql/data' '-p' '5433' '-B' '128'
316 </computeroutput>
317 </screen>
318     This is the command line that would be invoked in restart mode.
319    </para>
320   </refsect2>
321  </refsect1>
322
323  <refsect1>
324   <title>Bugs</title>
325
326   <para>
327    Waiting for complete start is not a well-defined operation and may
328    fail if access control is set up in way that a local client cannot
329    connect without manual interaction.  It should be avoided.
330   </para>
331  </refsect1>
332
333  <refsect1>
334   <title>See Also</title>
335
336   <para>
337    <xref linkend="app-postmaster">, <citetitle>PostgreSQL Administrator's Guide</citetitle>
338   </para>
339  </refsect1>
340
341 </refentry>
342
343 <!-- Keep this comment at the end of the file
344 Local variables:
345 mode:sgml
346 sgml-omittag:nil
347 sgml-shorttag:t
348 sgml-minimize-attributes:nil
349 sgml-always-quote-attributes:t
350 sgml-indent-step:1
351 sgml-indent-data:t
352 sgml-parent-document:nil
353 sgml-default-dtd-file:"../reference.ced"
354 sgml-exposed-tags:nil
355 sgml-local-catalogs:("/usr/lib/sgml/catalog")
356 sgml-local-ecat-files:nil
357 End:
358 -->