

If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. "Smart" mode waits for all active clients to disconnect and any online backup to finish. Three different shutdown methods can be selected with the -m option. In stop mode, the server that is running in the specified data directory is shut down. Use of either -l or output redirection is recommended. These default behaviors can be changed by using -l to append the server's output to a log file. On Windows, by default the server's standard output and standard error are sent to the terminal. The standard output of pg_ctl should then be redirected to a file or piped to another process such as a log rotating program like rotatelogs otherwise postgres will write its output to the controlling terminal (from the background) and will not leave the shell's process group.

On Unix-like systems, by default, the server's standard output and standard error are sent to pg_ctl's standard output (not standard error). The server is started in the background, and its standard input is attached to /dev/null (or nul on Windows). A database cluster is a collection of databases that are managed by a single server instance. The init or initdb mode creates a new PostgreSQL database cluster. It also provides convenient options for controlled shutdown. Although the server can be started manually, pg_ctl encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. Pg_ctl is a utility for initializing a PostgreSQL database cluster, starting, stopping, or restarting the PostgreSQL database server ( postgres), or displaying the status of a running server.
