2000-11-25pg_ctl1Applicationpg_ctlStarts, stops, or restarts postmasterpg_ctlstart-w-D datadir-p path-o optionspg_ctlstop-w-D datadir-m
s[mart]f[ast]i[mmediate]pg_ctlrestart-w-D datadir-m
s[mart]f[ast]i[mmediate]-o optionspg_ctlstatus-D datadirDescriptionpg_ctl is a utility for starting,
stopping, or restarting the , or displaying the status of a
running postmaster.
Options-w
Wait for the database server to come up, by watching for
creation of the pid file
(PGDATA/postmaster.pid).
Times out after 60 seconds.
-D datadir
Specifies the file system location of the database files. If
this is omitted, the environment variable
PGDATA is used.
-p path
Specifies the location of the postmaster
executable. By default the postmaster is taken from the same
directory as pg_ctl, or failing that, the hard-wired
installation directory. It is not necessary to use this
option unless you are doing something unusual and get errors
that the postmaster was not found.
-o options
Specifies options to be passed directly to
postmaster.
The parameters are usually surrounded by single or double
quotes to ensure that they are passed through as a group.
-m mode
Specifies the shutdown mode.
smarts
Smart mode waits for all the clients to disconnect. This
is the default.
fastf
Fast mode does not wait for clients to disconnect. All
active transactions will be rolled back.
immediatei
Immediate mode will abort without complete shutdown. This
will lead to a recovery run on restart.
start
Start up postmaster.
stop
Shut down postmaster.
restart
Stop the postmaster, if one is running,
and then start it again.
status
Show the current state of postmaster.
Files
If the file postmaster.opts.default exists in
the data directory, the contents of the file will be passed as
options to the postmaster, unless
overridden by the option.
UsageStarting the postmaster
To start up postmaster:
$pg_ctl start
An example of starting the postmaster,
blocking until postmaster comes up is:
$pg_ctl -w start
For a postmaster using port 5433, and
running without fsync, use:
$pg_ctl -o "-F -p 5433" startStopping the postmaster$pg_ctl stop
stops postmaster. Using the switch allows one
to control how the backend shuts down.
waits for postmaster to shut down.
Restarting the postmaster
This is almost equivalent to stopping the
postmaster then starting it again
except that pg_ctl saves and reuses the command line options that
were passed to the previously running instance. To restart
postmaster in the simplest form:
$pg_ctl restart
To restart postmaster,
waiting for it to shut down and to come up:
$pg_ctl -w restart
To restart using port 5433 and disabling fsync after restarting:
$pg_ctl -o "-F -p 5433" restartShowing postmaster status
Here is a sample status output from
pg_ctl:
$pg_ctl status
pg_ctl: postmaster is running (pid: 13718)
Command line was:
/usr/local/pgsql/bin/postmaster '-D' '/usr/local/pgsql/data' '-p' '5433' '-B' '128'
This is the command line that would be invoked in restart mode.