pg_ctl  --  Starts, stops, and restarts postmaster.


pg_ctl [-w] [-D datadir][-p path] [-o "options"] start
pg_ctl [-w] [-D datadir] [-m [s[mart]|f[ast]|i[mmediate]]] stop
pg_ctl [-w] [-D datadir] [-m [s[mart]|f[ast]|i[mmediate]] [-o "options"] restart
pg_ctl [-D datadir] status



Pass this parameter to wait for the startup or shutdown of the database. Waiting will time out after 60 seconds.

-D datadir

Use this parameter to specify the location of the database directory for the database you are attempting to start. The environmental variable PGDATA is used if this is not given.

-p path

Use this option to supply the filesystem location of your postmaster binary file. This is usually not necessary.

-o "options"

Use this parameter to pass options directly to postmaster . Use single or double quotes to make sure they are passed as a group.

-m mode

Use this parameter to set the shutdown mode, where mode is one of the following.

smart, s

Smart mode waits for all the clients to logout. This is the default.

f[ast], f

Fast mode sends SIGTERM to the backends, causing all active transactions to be rolled back.

immediate, i

Immediate mode sends SIGUSR1 to the backends and lets them abort. Database recovery will be necessary on the next startup when using this mode.


Use this parameter to start the database.


Use this parameter to shutdown postmaster.


Use this parameter to restart postmaster. This performs a shutdown and startup.


Use this parameter to display the current state of postmaster.


pg_ctl: postmaster is state (pid: #)

This message displays the state postmaster is running in and its system pid.


Use pg_ctl to start, stop, and restart postmaster. This program will look for the postmaster.opts.default file in the data directory and pass its contents on to postmaster, unless overridden by the -o option.


The following example starts postmaster using pg_ctl .

$ pg_ctl start

The next example stops postmaster using pg_ctl.

$ pg_ctl stop

The following example restarts postmaster.

$ pg_ctl restart