.\\" auto-generated by docbook2man-spec $Revision: 1.25 $ .TH "PG_CTL" "1" "2002-11-22" "Application" "PostgreSQL Server Applications" .SH NAME pg_ctl \- start, stop, or restart a PostgreSQL server .SH SYNOPSIS .sp \fBpg_ctl\fR \fBstart\fR\fR [ \fR\fB-w \fR\fR]\fR\fR [ \fR\fB-s \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR\fR [ \fR\fB-l \fIfilename\fB \fR\fR]\fR\fR [ \fR\fB-o \fIoptions\fB \fR\fR]\fR\fR [ \fR\fB-p \fIpath\fB \fR\fR]\fR \fBpg_ctl\fR \fBstop\fR\fR [ \fR\fB-W \fR\fR]\fR\fR [ \fR\fB-s \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR\fR [ \fR\fB-m \fR\fB s[mart]\fR | \fBf[ast]\fR | \fBi[mmediate]\fR\fB \fR\fR]\fR \fBpg_ctl\fR \fBrestart\fR\fR [ \fR\fB-w \fR\fR]\fR\fR [ \fR\fB-s \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR\fR [ \fR\fB-m \fR\fB s[mart]\fR | \fBf[ast]\fR | \fBi[mmediate]\fR\fB \fR\fR]\fR\fR [ \fR\fB-o \fIoptions\fB \fR\fR]\fR \fBpg_ctl\fR \fBreload\fR\fR [ \fR\fB-s \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR \fBpg_ctl\fR \fBstatus\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR .SH "DESCRIPTION" .PP \fBpg_ctl\fR is a utility for starting, stopping, or restarting \fBpostmaster\fR(1), the PostgreSQL backend server, or displaying the status of a running postmaster. Although the postmaster can be started manually, \fBpg_ctl\fR encapsulates tasks such as redirecting log output, properly detaching from the terminal and process group, and it provides convenient options for controlled shutdown. .PP In \fBstart\fR mode, a new postmaster is launched. The server is started in the background, the standard input attached to \fI/dev/null\fR. The standard output and standard error are either appended to a log file, if the \fB-l\fR option is used, or are redirected to \fBpg_ctl\fR's standard output (not standard error). If no log file is chosen, the standard output of \fBpg_ctl\fR should be redirected to a file or piped to another process, for example a log rotating program, otherwise the postmaster will write its output the the controlling terminal (from the background) and will not leave the shell's process group. .PP In \fBstop\fR mode, the postmaster that is running in the specified data directory is shut down. Three different shutdown methods can be selected with the \fB-m\fR option: ``Smart'' mode waits for all the clients to disconnect. This is the default. ``Fast'' mode does not wait for clients to disconnect. All active transactions are rolled back and clients are forcibly disconnected, then the database is shut down. ``Immediate'' mode will abort all server processes without clean shutdown. This will lead to a recovery run on restart. .PP \fBrestart\fR mode effectively executes a stop followed by a start. This allows the changing of postmaster command line options. .PP \fBreload\fR mode simply sends the postmaster a \fBSIGHUP\fR signal, causing it to reread its configuration files (\fIpostgresql.conf\fR, \fIpg_hba.conf\fR, etc.). This allows changing of configuration-file options that do not require a complete restart to take effect. .PP \fBstatus\fR mode checks whether a postmaster is running and if so displays the PID and the command line options that were used to invoke it. .SH "OPTIONS" .PP .TP \fB-D \fIdatadir\fB\fR Specifies the file system location of the database files. If this is omitted, the environment variable \fBPGDATA\fR is used. .TP \fB-l \fIfilename\fB\fR Append the server log output to \fIfilename\fR. If the file does not exist, it is created. The \fBumask\fR is set to 077, so access to the log file from other users is disallowed by default. .TP \fB-m \fImode\fB\fR Specifies the shutdown mode. \fImode\fR may be smart, fast, or immediate, or the first letter of one of these three. .TP \fB-o \fIoptions\fB\fR Specifies options to be passed directly to \fBpostmaster\fR. The parameters are usually surrounded by single or double quotes to ensure that they are passed through as a group. .TP \fB-p \fIpath\fB\fR Specifies the location of the \fIpostmaster\fR executable. By default the postmaster is taken from the same directory as \fBpg_ctl\fR, 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. .TP \fB-s\fR Only print errors, no informational messages. .TP \fB-w\fR Wait for the start or shutdown to complete. Times out after 60 seconds. This is the default for shutdowns. .TP \fB-W\fR Do not wait for start or shutdown to complete. This is the default for starts and restarts. .PP .SH "ENVIRONMENT" .TP \fBPGDATA\fR Default data direction location .PP For others, see \fBpostmaster\fR(1). .PP .SH "FILES" .PP If the file \fIpostmaster.opts.default\fR exists in the data directory, the contents of the file will be passed as options to the \fBpostmaster\fR, unless overridden by the \fB-o\fR option. .SH "NOTES" .PP Waiting for complete start is not a well-defined operation and may fail if access control is set up so that a local client cannot connect without manual interaction. It should be avoided. .SH "EXAMPLES" .SS "STARTING THE POSTMASTER" .PP To start up a \fBpostmaster\fR: .sp .nf $ \fBpg_ctl start\fR .sp .fi .PP An example of starting the \fBpostmaster\fR, blocking until the postmaster comes up is: .sp .nf $ \fBpg_ctl -w start\fR .sp .fi .PP For a \fBpostmaster\fR using port 5433, and running without \fBfsync\fR, use: .sp .nf $ \fBpg_ctl -o "-F -p 5433" start\fR .sp .fi .SS "STOPPING THE POSTMASTER" .PP .sp .nf $ \fBpg_ctl stop\fR .sp .fi stops the postmaster. Using the \fB-m\fR switch allows one to control \fBhow\fR the backend shuts down. .SS "RESTARTING THE POSTMASTER" .PP This is almost equivalent to stopping the \fBpostmaster\fR and starting it again except that \fBpg_ctl\fR saves and reuses the command line options that were passed to the previously running instance. To restart the \fBpostmaster\fR in the simplest form: .sp .nf $ \fBpg_ctl restart\fR .sp .fi .PP To restart \fBpostmaster\fR, waiting for it to shut down and to come up: .sp .nf $ \fBpg_ctl -w restart\fR .sp .fi .PP To restart using port 5433 and disabling \fBfsync\fR after restarting: .sp .nf $ \fBpg_ctl -o "-F -p 5433" restart\fR .sp .fi .SS "SHOWING POSTMASTER STATUS" .PP Here is a sample status output from \fBpg_ctl\fR: .sp .nf $ \fBpg_ctl status\fR pg_ctl: postmaster is running (pid: 13718) Command line was: /usr/local/pgsql/bin/postmaster '-D' '/usr/local/pgsql/data' '-p' '5433' '-B' '128' .sp .fi This is the command line that would be invoked in restart mode. .SH "SEE ALSO" .PP \fBpostmaster\fR(1), \fIPostgreSQL Administrator's Guide\fR