{"Entry":{"collection":"tool","key":"pg-ctl","name":"pg_ctl","aliases":["pg_ctl"],"metadata":{"aliases":["pg_ctl"],"category":"Server applications","content_hash":"5aadba1119910e63d661fae71ee80b57a239eb75b5fe35d3764c71d85dda2db3","imported_at":"2026-09-30T00:40:34.145525+08:00","name":"pg_ctl","name_zh":"","slug":"pg-ctl","summary":"pg_ctl — initialize, start, stop, or control a PostgreSQL server"}},"Definition":{"Collection":"tool","Key":"pg-ctl","SourceDatabase":"center","Version":"18","SourceTable":"command_tool","SourceKey":"pg-ctl","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"environment":[{"description":"Default limit on the number of seconds to wait when waiting for startup or shutdown to complete. If not set, the default is 60 seconds.","name":"PGCTLTIMEOUT"},{"description":"Default data directory location.","name":"PGDATA"}],"options":[{"description":"Attempt to allow server crashes to produce core files, on platforms where this is possible, by lifting any soft resource limit placed on core files. This is useful in debugging or diagnosing problems by allowing a stack trace to be obtained from a failed server process.","names":["-c","--core-files"],"signature":"-c --core-files"},{"description":"Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.","names":["-D datadir","--pgdata= datadir"],"signature":"-D datadir --pgdata= datadir"},{"description":"Append the server log output to filename . If the file does not exist, it is created. By default, only the cluster owner can access the log file. If group access is enabled in the cluster, users in the same group as the cluster owner can also read it.","names":["-l filename","--log= filename"],"signature":"-l filename --log= filename"},{"description":"Specifies the shutdown mode. mode can be smart , fast , or immediate , or the first letter of one of these three. If this option is omitted, fast is the default.","names":["-m mode","--mode= mode"],"signature":"-m mode --mode= mode"},{"description":"Specifies options to be passed directly to the postgres command. -o can be specified multiple times, with all the given options being passed through. The options should usually be surrounded by single or double quotes to ensure that they are passed through as a group.","names":["-o options","--options= options"],"signature":"-o options --options= options"},{"description":"Specifies options to be passed directly to the initdb command. -o can be specified multiple times, with all the given options being passed through. The initdb-options should usually be surrounded by single or double quotes to ensure that they are passed through as a group.","names":["-o initdb-options","--options= initdb-options"],"signature":"-o initdb-options --options= initdb-options"},{"description":"Specifies the location of the postgres executable. By default the postgres executable 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 postgres executable was not found. In init mode, this option analogously specifies the location of the initdb executable.","names":["-p path"],"signature":"-p path"},{"description":"Print only errors, no informational messages.","names":["-s","--silent"],"signature":"-s --silent"},{"description":"Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option -w ). Defaults to the value of the PGCTLTIMEOUT environment variable or, if not set, to 60 seconds.","names":["-t seconds","--timeout= seconds"],"signature":"-t seconds --timeout= seconds"},{"description":"Print the pg_ctl version and exit.","names":["-V","--version"],"signature":"-V --version"},{"description":"Wait for the operation to complete. This is supported for the modes start , stop , restart , promote , and register , and is the default for those modes. When waiting, pg_ctl repeatedly checks the server's PID file, sleeping for a short amount of time between checks. Startup is considered complete when the PID file indicates that the server is ready to accept connections. Shutdown is considered complete when the server removes the PID file. pg_ctl returns an exit code based on the success of the startup or shutdown. If the operation does not complete within the timeout (see option -t ), then pg_ctl exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.","names":["-w","--wait"],"signature":"-w --wait"},{"description":"Do not wait for the operation to complete. This is the opposite of the option -w . If waiting is disabled, the requested action is triggered, but there is no feedback about its success. In that case, the server log file or an external monitoring system would have to be used to check the progress and success of the operation. In prior releases of PostgreSQL, this was the default except for the stop mode.","names":["-W","--no-wait"],"signature":"-W --no-wait"},{"description":"Show help about pg_ctl command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help"},{"description":"Name of the event source for pg_ctl to use for logging to the event log when running as a Windows service. The default is PostgreSQL . Note that this only controls messages sent from pg_ctl itself; once started, the server will use the event source specified by its event_source parameter. Should the server fail very early in startup, before that parameter has been set, it might also log using the default event source name PostgreSQL .","names":["-e source"],"signature":"-e source"},{"description":"Name of the system service to register. This name will be used as both the service name and the display name. The default is PostgreSQL .","names":["-N servicename"],"signature":"-N servicename"},{"description":"Password for the user to run the service as.","names":["-P password"],"signature":"-P password"},{"description":"Start type of the system service. start-type can be auto , or demand , or the first letter of one of these two. If this option is omitted, auto is the default.","names":["-S start-type"],"signature":"-S start-type"},{"description":"User name for the user to run the service as. For domain users, use the format DOMAIN\\username .","names":["-U username"],"signature":"-U username"}],"synopsis":["pg_ctl init[db] [ -D datadir ] [ -s ] [ -o initdb-options ]","pg_ctl start [ -D datadir ] [ -l filename ] [ -W ] [ -t seconds ] [ -s ] [ -o options ] [ -p path ] [ -c ]","pg_ctl stop [ -D datadir ] [ -m s[mart] | f[ast] | i[mmediate] ] [ -W ] [ -t seconds ] [ -s ]","pg_ctl restart [ -D datadir ] [ -m s[mart] | f[ast] | i[mmediate] ] [ -W ] [ -t seconds ] [ -s ] [ -o options ] [ -c ]","pg_ctl reload [ -D datadir ] [ -s ]","pg_ctl status [ -D datadir ]","pg_ctl promote [ -D datadir ] [ -W ] [ -t seconds ] [ -s ]","pg_ctl logrotate [ -D datadir ] [ -s ]","pg_ctl kill signal_name process_id","pg_ctl register [ -D datadir ] [ -N servicename ] [ -U username ] [ -P password ] [ -S a[uto] | d[emand] ] [ -e source ] [ -W ] [ -t seconds ] [ -s ] [ -o options ]","pg_ctl unregister [ -N servicename ]"]},"comparison_hash":"4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53","description":["pg_ctl — initialize, start, stop, or control a PostgreSQL server"],"environment":[{"description":"Default limit on the number of seconds to wait when waiting for startup or shutdown to complete. If not set, the default is 60 seconds.","name":"PGCTLTIMEOUT"},{"description":"Default data directory location.","name":"PGDATA"}],"facts":[{"label":"Documented executable","value":"pg_ctl"},{"label":"Executable version","value":"18.6"},{"label":"Reference inventory","value":"Server applications"},{"label":"Option definition groups","value":"18"}],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PG-CTL\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_ctl — initialize, start, stop, or control a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.1\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003einit[db]\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-o\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.2\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003estart\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-l\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-o\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-p\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-c\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.3\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003estop\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-m\u003c/code\u003e \u003ccode class=\"option\"\u003es[mart]\u003c/code\u003e | \u003ccode class=\"option\"\u003ef[ast]\u003c/code\u003e | \u003ccode class=\"option\"\u003ei[mmediate]\u003c/code\u003e ] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.4\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003erestart\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-m\u003c/code\u003e \u003ccode class=\"option\"\u003es[mart]\u003c/code\u003e | \u003ccode class=\"option\"\u003ef[ast]\u003c/code\u003e | \u003ccode class=\"option\"\u003ei[mmediate]\u003c/code\u003e ] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-o\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-c\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.5\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003ereload\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.6\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003estatus\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.7\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003epromote\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.8\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003elogrotate\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.9\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003ekill\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esignal_name\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprocess_id\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eOn Microsoft Windows, also:\u003c/p\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.11\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003eregister\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-N\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-U\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-P\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003epassword\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-S\u003c/code\u003e \u003ccode class=\"option\"\u003ea[uto]\u003c/code\u003e | \u003ccode class=\"option\"\u003ed[emand]\u003c/code\u003e ] [\u003ccode class=\"option\"\u003e-e\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-o\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.12\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003eunregister\u003c/code\u003e [\u003ccode class=\"option\"\u003e-N\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e is a utility for initializing a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster, starting, stopping, or restarting the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database server (\u003ca class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e), or displaying the status of a running server. Although the server can be started manually, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"option\"\u003einit\u003c/code\u003e or \u003ccode class=\"option\"\u003einitdb\u003c/code\u003e mode creates a new \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e command. See \u003ca class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e for details.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003estart\u003c/code\u003e mode launches a new server. The server is started in the background, and its standard input is attached to \u003ccode class=\"filename\"\u003e/dev/null\u003c/code\u003e (or \u003ccode class=\"literal\"\u003enul\u003c/code\u003e on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e's standard output (not standard error). The standard output of \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e should then be redirected to a file or piped to another process such as a log rotating program like \u003cspan class=\"application\"\u003erotatelogs\u003c/span\u003e; otherwise \u003ccode class=\"command\"\u003epostgres\u003c/code\u003e will write its output to the controlling terminal (from the background) and will not leave the shell's process group. On Windows, by default the server's standard output and standard error are sent to the terminal. These default behaviors can be changed by using \u003ccode class=\"option\"\u003e-l\u003c/code\u003e to append the server's output to a log file. Use of either \u003ccode class=\"option\"\u003e-l\u003c/code\u003e or output redirection is recommended.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003estop\u003c/code\u003e mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the \u003ccode class=\"option\"\u003e-m\u003c/code\u003e option. \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eSmart\u003c/span\u003e”\u003c/span\u003e mode disallows new connections, then waits for all existing clients to disconnect. If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eFast\u003c/span\u003e”\u003c/span\u003e mode (the default) does not wait for clients to disconnect. All active transactions are rolled back and clients are forcibly disconnected, then the server is shut down. \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eImmediate\u003c/span\u003e”\u003c/span\u003e mode will abort all server processes immediately, without a clean shutdown. This choice will lead to a crash-recovery cycle during the next server start.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003erestart\u003c/code\u003e mode effectively executes a stop followed by a start. This allows changing the \u003ccode class=\"command\"\u003epostgres\u003c/code\u003e command-line options, or changing configuration-file options that cannot be changed without restarting the server. If relative paths were used on the command line during server start, \u003ccode class=\"option\"\u003erestart\u003c/code\u003e might fail unless \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e is executed in the same current directory as it was during server start.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003ereload\u003c/code\u003e mode simply sends the \u003ccode class=\"command\"\u003epostgres\u003c/code\u003e server process a \u003cspan class=\"systemitem\"\u003eSIGHUP\u003c/span\u003e signal, causing it to reread its configuration files (\u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e, \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003estatus\u003c/code\u003e mode checks whether a server is running in the specified data directory. If it is, the server's PID and the command line options that were used to invoke it are displayed. If the server is not running, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e returns an exit status of 3. If an accessible data directory is not specified, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e returns an exit status of 4.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003epromote\u003c/code\u003e mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003elogrotate\u003c/code\u003e mode rotates the server log file. For details on how to use this mode with external log rotation tools, see \u003ca class=\"xref\" href=\"/docs/18/logfile-maintenance.html\" title=\"24.3. Log File Maintenance\"\u003eSection 24.3\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003ekill\u003c/code\u003e mode sends a signal to a specified process. This is primarily valuable on \u003cspan class=\"productname\"\u003eMicrosoft Windows\u003c/span\u003e which does not have a built-in \u003cspan class=\"application\"\u003ekill\u003c/span\u003e command. Use \u003ccode class=\"literal\"\u003e--help\u003c/code\u003e to see a list of supported signal names.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003eregister\u003c/code\u003e mode registers the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server as a system service on \u003cspan class=\"productname\"\u003eMicrosoft Windows\u003c/span\u003e. The \u003ccode class=\"option\"\u003e-S\u003c/code\u003e option allows selection of service start type, either \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eauto\u003c/span\u003e”\u003c/span\u003e (start service automatically on system startup) or \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edemand\u003c/span\u003e”\u003c/span\u003e (start service on demand).\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003eunregister\u003c/code\u003e mode unregisters a system service on \u003cspan class=\"productname\"\u003eMicrosoft Windows\u003c/span\u003e. This undoes the effects of the \u003ccode class=\"option\"\u003eregister\u003c/code\u003e command.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--core-files\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAttempt to allow server crashes to produce core files, on platforms where this is possible, by lifting any soft resource limit placed on core files. This is useful in debugging or diagnosing problems by allowing a stack trace to be obtained from a failed server process.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the file system location of the database configuration files. If this option is omitted, the environment variable \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAppend the server log output to \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. If the file does not exist, it is created. By default, only the cluster owner can access the log file. If group access is enabled in the cluster, users in the same group as the cluster owner can also read it.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-m \u003cem class=\"replaceable\"\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--mode=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the shutdown mode. \u003cem class=\"replaceable\"\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e can be \u003ccode class=\"literal\"\u003esmart\u003c/code\u003e, \u003ccode class=\"literal\"\u003efast\u003c/code\u003e, or \u003ccode class=\"literal\"\u003eimmediate\u003c/code\u003e, or the first letter of one of these three. If this option is omitted, \u003ccode class=\"literal\"\u003efast\u003c/code\u003e is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--options=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be passed directly to the \u003ccode class=\"command\"\u003epostgres\u003c/code\u003e command. \u003ccode class=\"option\"\u003e-o\u003c/code\u003e can be specified multiple times, with all the given options being passed through.\u003c/p\u003e\n\u003cp\u003eThe \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e should usually be surrounded by single or double quotes to ensure that they are passed through as a group.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--options=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be passed directly to the \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e command. \u003ccode class=\"option\"\u003e-o\u003c/code\u003e can be specified multiple times, with all the given options being passed through.\u003c/p\u003e\n\u003cp\u003eThe \u003cem class=\"replaceable\"\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e should usually be surrounded by single or double quotes to ensure that they are passed through as a group.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the \u003ccode class=\"filename\"\u003epostgres\u003c/code\u003e executable. By default the \u003ccode class=\"filename\"\u003epostgres\u003c/code\u003e executable is taken from the same directory as \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e, 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 \u003ccode class=\"filename\"\u003epostgres\u003c/code\u003e executable was not found.\u003c/p\u003e\n\u003cp\u003eIn \u003ccode class=\"literal\"\u003einit\u003c/code\u003e mode, this option analogously specifies the location of the \u003ccode class=\"filename\"\u003einitdb\u003c/code\u003e executable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--silent\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint only errors, no informational messages.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--timeout=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the maximum number of seconds to wait when waiting for an operation to complete (see option \u003ccode class=\"option\"\u003e-w\u003c/code\u003e). Defaults to the value of the \u003ccode class=\"envar\"\u003ePGCTLTIMEOUT\u003c/code\u003e environment variable or, if not set, to 60 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wait\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWait for the operation to complete. This is supported for the modes \u003ccode class=\"literal\"\u003estart\u003c/code\u003e, \u003ccode class=\"literal\"\u003estop\u003c/code\u003e, \u003ccode class=\"literal\"\u003erestart\u003c/code\u003e, \u003ccode class=\"literal\"\u003epromote\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eregister\u003c/code\u003e, and is the default for those modes.\u003c/p\u003e\n\u003cp\u003eWhen waiting, \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e repeatedly checks the server's PID file, sleeping for a short amount of time between checks. Startup is considered complete when the PID file indicates that the server is ready to accept connections. Shutdown is considered complete when the server removes the PID file. \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e returns an exit code based on the success of the startup or shutdown.\u003c/p\u003e\n\u003cp\u003eIf the operation does not complete within the timeout (see option \u003ccode class=\"option\"\u003e-t\u003c/code\u003e), then \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-wait\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not wait for the operation to complete. This is the opposite of the option \u003ccode class=\"option\"\u003e-w\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf waiting is disabled, the requested action is triggered, but there is no feedback about its success. In that case, the server log file or an external monitoring system would have to be used to check the progress and success of the operation.\u003c/p\u003e\n\u003cp\u003eIn prior releases of PostgreSQL, this was the default except for the \u003ccode class=\"literal\"\u003estop\u003c/code\u003e mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eIf an option is specified that is valid, but not relevant to the selected operating mode, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e ignores it.\u003c/p\u003e\n\u003cdiv class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\"\u003e\n\u003ch3\u003eOptions for Windows\u003c/h3\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eName of the event source for \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e to use for logging to the event log when running as a Windows service. The default is \u003ccode class=\"literal\"\u003ePostgreSQL\u003c/code\u003e. Note that this only controls messages sent from \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e itself; once started, the server will use the event source specified by its \u003ca class=\"xref\" href=\"/docs/18/runtime-config-logging.html#GUC-EVENT-SOURCE\"\u003eevent_source\u003c/a\u003e parameter. Should the server fail very early in startup, before that parameter has been set, it might also log using the default event source name \u003ccode class=\"literal\"\u003ePostgreSQL\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N \u003cem class=\"replaceable\"\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eName of the system service to register. This name will be used as both the service name and the display name. The default is \u003ccode class=\"literal\"\u003ePostgreSQL\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P \u003cem class=\"replaceable\"\u003e\u003ccode\u003epassword\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePassword for the user to run the service as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003estart-type\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStart type of the system service. \u003cem class=\"replaceable\"\u003e\u003ccode\u003estart-type\u003c/code\u003e\u003c/em\u003e can be \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e, or \u003ccode class=\"literal\"\u003edemand\u003c/code\u003e, or the first letter of one of these two. If this option is omitted, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUser name for the user to run the service as. For domain users, use the format \u003ccode class=\"literal\"\u003eDOMAIN\\username\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.8.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGCTLTIMEOUT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault limit on the number of seconds to wait when waiting for startup or shutdown to complete. If not set, the default is 60 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault data directory location.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eMost \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e modes require knowing the data directory location; therefore, the \u003ccode class=\"option\"\u003e-D\u003c/code\u003e option is required unless \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e is set.\u003c/p\u003e\n\u003cp\u003eFor additional variables that affect the server, see \u003ca class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.8.8\"\u003e\n\u003ch2\u003eFiles\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"filename\"\u003epostmaster.pid\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e examines this file in the data directory to determine whether the server is currently running.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"filename\"\u003epostmaster.opts\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this file exists in the data directory, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e (in \u003ccode class=\"option\"\u003erestart\u003c/code\u003e mode) will pass the contents of the file as options to \u003cspan class=\"application\"\u003epostgres\u003c/span\u003e, unless overridden by the \u003ccode class=\"option\"\u003e-o\u003c/code\u003e option. The contents of this file are also displayed in \u003ccode class=\"option\"\u003estatus\u003c/code\u003e mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"R1-APP-PGCTL-2\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PGCTL-3\"\u003e\n\u003ch3\u003eStarting the Server\u003c/h3\u003e\n\u003cp\u003eTo start the server, waiting until the server is accepting connections:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl start\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo start the server using port 5433, and running without \u003ccode class=\"function\"\u003efsync\u003c/code\u003e, use:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl -o \"-F -p 5433\" start\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PGCTL-4\"\u003e\n\u003ch3\u003eStopping the Server\u003c/h3\u003e\n\u003cp\u003eTo stop the server, use:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl stop\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eThe \u003ccode class=\"option\"\u003e-m\u003c/code\u003e option allows control over \u003cspan class=\"emphasis\"\u003e\u003cem\u003ehow\u003c/em\u003e\u003c/span\u003e the server shuts down:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl stop -m smart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PGCTL-5\"\u003e\n\u003ch3\u003eRestarting the Server\u003c/h3\u003e\n\u003cp\u003eRestarting the server is almost equivalent to stopping the server and starting it again, except that by default, \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e saves and reuses the command line options that were passed to the previously-running instance. To restart the server using the same options as before, use:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl restart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eBut if \u003ccode class=\"option\"\u003e-o\u003c/code\u003e is specified, that replaces any previous options. To restart using port 5433, disabling \u003ccode class=\"function\"\u003efsync\u003c/code\u003e upon restart:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl -o \"-F -p 5433\" restart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PGCTL-6\"\u003e\n\u003ch3\u003eShowing the Server Status\u003c/h3\u003e\n\u003cp\u003eHere is sample status output from \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl status\u003c/code\u003e\u003c/strong\u003e\n\u003ccode class=\"computeroutput\"\u003e\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n\u003c/code\u003e\n\u003c/pre\u003e\n\u003cp\u003eThe second line is the command that would be invoked in restart mode.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.8.10\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","manual_path":"app-pg-ctl.html","options":[{"description":"Attempt to allow server crashes to produce core files, on platforms where this is possible, by lifting any soft resource limit placed on core files. This is useful in debugging or diagnosing problems by allowing a stack trace to be obtained from a failed server process.","names":["-c","--core-files"],"signature":"-c --core-files","source_url":"/docs/18/app-pg-ctl.html","summary":"Attempt to allow server crashes to produce core files, on platforms where this is possible, by lifting any soft resource limit placed on core files. This is useful in debugging or diagnosing problems by allowing a stack trace to be obtained from a failed server process."},{"description":"Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.","names":["-D datadir","--pgdata= datadir"],"signature":"-D datadir --pgdata= datadir","source_url":"/docs/18/app-pg-ctl.html","summary":"Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."},{"description":"Append the server log output to filename . If the file does not exist, it is created. By default, only the cluster owner can access the log file. If group access is enabled in the cluster, users in the same group as the cluster owner can also read it.","names":["-l filename","--log= filename"],"signature":"-l filename --log= filename","source_url":"/docs/18/app-pg-ctl.html","summary":"Append the server log output to filename . If the file does not exist, it is created. By default, only the cluster owner can access the log file. If group access is enabled in the cluster, users in the same group as the cluster owner can also read it."},{"description":"Specifies the shutdown mode. mode can be smart , fast , or immediate , or the first letter of one of these three. If this option is omitted, fast is the default.","names":["-m mode","--mode= mode"],"signature":"-m mode --mode= mode","source_url":"/docs/18/app-pg-ctl.html","summary":"Specifies the shutdown mode. mode can be smart , fast , or immediate , or the first letter of one of these three. If this option is omitted, fast is the default."},{"description":"Specifies options to be passed directly to the postgres command. -o can be specified multiple times, with all the given options being passed through. The options should usually be surrounded by single or double quotes to ensure that they are passed through as a group.","names":["-o options","--options= options"],"signature":"-o options --options= options","source_url":"/docs/18/app-pg-ctl.html","summary":"Specifies options to be passed directly to the postgres command. -o can be specified multiple times, with all the given options being passed through."},{"description":"Specifies options to be passed directly to the initdb command. -o can be specified multiple times, with all the given options being passed through. The initdb-options should usually be surrounded by single or double quotes to ensure that they are passed through as a group.","names":["-o initdb-options","--options= initdb-options"],"signature":"-o initdb-options --options= initdb-options","source_url":"/docs/18/app-pg-ctl.html","summary":"Specifies options to be passed directly to the initdb command. -o can be specified multiple times, with all the given options being passed through."},{"description":"Specifies the location of the postgres executable. By default the postgres executable 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 postgres executable was not found. In init mode, this option analogously specifies the location of the initdb executable.","names":["-p path"],"signature":"-p path","source_url":"/docs/18/app-pg-ctl.html","summary":"Specifies the location of the postgres executable. By default the postgres executable 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 postgres executable was not found."},{"description":"Print only errors, no informational messages.","names":["-s","--silent"],"signature":"-s --silent","source_url":"/docs/18/app-pg-ctl.html","summary":"Print only errors, no informational messages."},{"description":"Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option -w ). Defaults to the value of the PGCTLTIMEOUT environment variable or, if not set, to 60 seconds.","names":["-t seconds","--timeout= seconds"],"signature":"-t seconds --timeout= seconds","source_url":"/docs/18/app-pg-ctl.html","summary":"Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option -w ). Defaults to the value of the PGCTLTIMEOUT environment variable or, if not set, to 60 seconds."},{"description":"Print the pg_ctl version and exit.","names":["-V","--version"],"signature":"-V --version","source_url":"/docs/18/app-pg-ctl.html","summary":"Print the pg_ctl version and exit."},{"description":"Wait for the operation to complete. This is supported for the modes start , stop , restart , promote , and register , and is the default for those modes. When waiting, pg_ctl repeatedly checks the server's PID file, sleeping for a short amount of time between checks. Startup is considered complete when the PID file indicates that the server is ready to accept connections. Shutdown is considered complete when the server removes the PID file. pg_ctl returns an exit code based on the success of the startup or shutdown. If the operation does not complete within the timeout (see option -t ), then pg_ctl exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.","names":["-w","--wait"],"signature":"-w --wait","source_url":"/docs/18/app-pg-ctl.html","summary":"Wait for the operation to complete. This is supported for the modes start , stop , restart , promote , and register , and is the default for those modes."},{"description":"Do not wait for the operation to complete. This is the opposite of the option -w . If waiting is disabled, the requested action is triggered, but there is no feedback about its success. In that case, the server log file or an external monitoring system would have to be used to check the progress and success of the operation. In prior releases of PostgreSQL, this was the default except for the stop mode.","names":["-W","--no-wait"],"signature":"-W --no-wait","source_url":"/docs/18/app-pg-ctl.html","summary":"Do not wait for the operation to complete. This is the opposite of the option -w ."},{"description":"Show help about pg_ctl command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help","source_url":"/docs/18/app-pg-ctl.html","summary":"Show help about pg_ctl command line arguments, and exit."},{"description":"Name of the event source for pg_ctl to use for logging to the event log when running as a Windows service. The default is PostgreSQL . Note that this only controls messages sent from pg_ctl itself; once started, the server will use the event source specified by its event_source parameter. Should the server fail very early in startup, before that parameter has been set, it might also log using the default event source name PostgreSQL .","names":["-e source"],"signature":"-e source","source_url":"/docs/18/app-pg-ctl.html","summary":"Name of the event source for pg_ctl to use for logging to the event log when running as a Windows service. The default is PostgreSQL . Note that this only controls messages sent from pg_ctl itself; once started, the server will use the event source specified by its event_source parameter. Should the server fail very early in startup, before that parameter has been set, it might also log using the default event source name PostgreSQL ."},{"description":"Name of the system service to register. This name will be used as both the service name and the display name. The default is PostgreSQL .","names":["-N servicename"],"signature":"-N servicename","source_url":"/docs/18/app-pg-ctl.html","summary":"Name of the system service to register. This name will be used as both the service name and the display name. The default is PostgreSQL ."},{"description":"Password for the user to run the service as.","names":["-P password"],"signature":"-P password","source_url":"/docs/18/app-pg-ctl.html","summary":"Password for the user to run the service as."},{"description":"Start type of the system service. start-type can be auto , or demand , or the first letter of one of these two. If this option is omitted, auto is the default.","names":["-S start-type"],"signature":"-S start-type","source_url":"/docs/18/app-pg-ctl.html","summary":"Start type of the system service. start-type can be auto , or demand , or the first letter of one of these two. If this option is omitted, auto is the default."},{"description":"User name for the user to run the service as. For domain users, use the format DOMAIN\\username .","names":["-U username"],"signature":"-U username","source_url":"/docs/18/app-pg-ctl.html","summary":"User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}],"related":[],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"pg_ctl init[db] [ -D datadir ] [ -s ] [ -o initdb-options ]\npg_ctl start [ -D datadir ] [ -l filename ] [ -W ] [ -t seconds ] [ -s ] [ -o options ] [ -p path ] [ -c ]\npg_ctl stop [ -D datadir ] [ -m s[mart] | f[ast] | i[mmediate] ] [ -W ] [ -t seconds ] [ -s ]\npg_ctl restart [ -D datadir ] [ -m s[mart] | f[ast] | i[mmediate] ] [ -W ] [ -t seconds ] [ -s ] [ -o options ] [ -c ]\npg_ctl reload [ -D datadir ] [ -s ]\npg_ctl status [ -D datadir ]\npg_ctl promote [ -D datadir ] [ -W ] [ -t seconds ] [ -s ]\npg_ctl logrotate [ -D datadir ] [ -s ]\npg_ctl kill signal_name process_id\npg_ctl register [ -D datadir ] [ -N servicename ] [ -U username ] [ -P password ] [ -S a[uto] | d[emand] ] [ -e source ] [ -W ] [ -t seconds ] [ -s ] [ -o options ]\npg_ctl unregister [ -N servicename ]","sources":[{"anchor":"","file":"app-pg-ctl.html","label":"18.6 English manual · app-pg-ctl.html","sha256":"bf10289e73df34e48912e8612d5df29f8a8145a2250627d8c099ed59eae23339","url":"/docs/18/app-pg-ctl.html"},{"anchor":"","file":"reference-server.html","label":"Server applications inventory","sha256":"e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3","url":"/docs/18/reference-server.html"}],"synopsis":["pg_ctl init[db] [ -D datadir ] [ -s ] [ -o initdb-options ]","pg_ctl start [ -D datadir ] [ -l filename ] [ -W ] [ -t seconds ] [ -s ] [ -o options ] [ -p path ] [ -c ]","pg_ctl stop [ -D datadir ] [ -m s[mart] | f[ast] | i[mmediate] ] [ -W ] [ -t seconds ] [ -s ]","pg_ctl restart [ -D datadir ] [ -m s[mart] | f[ast] | i[mmediate] ] [ -W ] [ -t seconds ] [ -s ] [ -o options ] [ -c ]","pg_ctl reload [ -D datadir ] [ -s ]","pg_ctl status [ -D datadir ]","pg_ctl promote [ -D datadir ] [ -W ] [ -t seconds ] [ -s ]","pg_ctl logrotate [ -D datadir ] [ -s ]","pg_ctl kill signal_name process_id","pg_ctl register [ -D datadir ] [ -N servicename ] [ -U username ] [ -P password ] [ -S a[uto] | d[emand] ] [ -e source ] [ -W ] [ -t seconds ] [ -s ] [ -o options ]","pg_ctl unregister [ -N servicename ]"],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-c --core-files","url":"/docs/18/app-pg-ctl.html"},"summary":"Attempt to allow server crashes to produce core files, on platforms where this is possible, by lifting any soft resource limit placed on core files. This is useful in debugging or diagnosing problems by allowing a stack trace to be obtained from a failed server process."},{"signature":{"text":"-D datadir --pgdata= datadir","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."},{"signature":{"text":"-l filename --log= filename","url":"/docs/18/app-pg-ctl.html"},"summary":"Append the server log output to filename . If the file does not exist, it is created. By default, only the cluster owner can access the log file. If group access is enabled in the cluster, users in the same group as the cluster owner can also read it."},{"signature":{"text":"-m mode --mode= mode","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies the shutdown mode. mode can be smart , fast , or immediate , or the first letter of one of these three. If this option is omitted, fast is the default."},{"signature":{"text":"-o options --options= options","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies options to be passed directly to the postgres command. -o can be specified multiple times, with all the given options being passed through."},{"signature":{"text":"-o initdb-options --options= initdb-options","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies options to be passed directly to the initdb command. -o can be specified multiple times, with all the given options being passed through."},{"signature":{"text":"-p path","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies the location of the postgres executable. By default the postgres executable 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 postgres executable was not found."},{"signature":{"text":"-s --silent","url":"/docs/18/app-pg-ctl.html"},"summary":"Print only errors, no informational messages."},{"signature":{"text":"-t seconds --timeout= seconds","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option -w ). Defaults to the value of the PGCTLTIMEOUT environment variable or, if not set, to 60 seconds."},{"signature":{"text":"-V --version","url":"/docs/18/app-pg-ctl.html"},"summary":"Print the pg_ctl version and exit."},{"signature":{"text":"-w --wait","url":"/docs/18/app-pg-ctl.html"},"summary":"Wait for the operation to complete. This is supported for the modes start , stop , restart , promote , and register , and is the default for those modes."},{"signature":{"text":"-W --no-wait","url":"/docs/18/app-pg-ctl.html"},"summary":"Do not wait for the operation to complete. This is the opposite of the option -w ."},{"signature":{"text":"-? --help","url":"/docs/18/app-pg-ctl.html"},"summary":"Show help about pg_ctl command line arguments, and exit."},{"signature":{"text":"-e source","url":"/docs/18/app-pg-ctl.html"},"summary":"Name of the event source for pg_ctl to use for logging to the event log when running as a Windows service. The default is PostgreSQL . Note that this only controls messages sent from pg_ctl itself; once started, the server will use the event source specified by its event_source parameter. Should the server fail very early in startup, before that parameter has been set, it might also log using the default event source name PostgreSQL ."},{"signature":{"text":"-N servicename","url":"/docs/18/app-pg-ctl.html"},"summary":"Name of the system service to register. This name will be used as both the service name and the display name. The default is PostgreSQL ."},{"signature":{"text":"-P password","url":"/docs/18/app-pg-ctl.html"},"summary":"Password for the user to run the service as."},{"signature":{"text":"-S start-type","url":"/docs/18/app-pg-ctl.html"},"summary":"Start type of the system service. start-type can be auto , or demand , or the first letter of one of these two. If this option is omitted, auto is the default."},{"signature":{"text":"-U username","url":"/docs/18/app-pg-ctl.html"},"summary":"User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Default limit on the number of seconds to wait when waiting for startup or shutdown to complete. If not set, the default is 60 seconds.","name":"PGCTLTIMEOUT"},{"description":"Default data directory location.","name":"PGDATA"}],"title":"Environment variables"}]},"ManualEvidence":{"manual_path":"app-pg-ctl.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"","file":"app-pg-ctl.html","label":"18.6 English manual · app-pg-ctl.html","sha256":"bf10289e73df34e48912e8612d5df29f8a8145a2250627d8c099ed59eae23339","url":"/docs/18/app-pg-ctl.html"},{"anchor":"","file":"reference-server.html","label":"Server applications inventory","sha256":"e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3","url":"/docs/18/reference-server.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"tool","Key":"pg-ctl","SourceDatabase":"center","Version":"18","Locale":"en","Title":"pg_ctl","Summary":"pg_ctl — initialize, start, stop, or control a PostgreSQL server","BodyHTML":"\u003cdiv\u003e\u003cdiv id=\"APP-PG-CTL\"\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003e\u003cspan\u003e\u003cspan\u003epg_ctl\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_ctl — initialize, start, stop, or control a \u003cspan\u003ePostgreSQL\u003c/span\u003e server\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.1\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003einit[db]\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-s\u003c/code\u003e] [\u003ccode\u003e-o\u003c/code\u003e \u003cem\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.2\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003estart\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-l\u003c/code\u003e \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-W\u003c/code\u003e] [\u003ccode\u003e-t\u003c/code\u003e \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-s\u003c/code\u003e] [\u003ccode\u003e-o\u003c/code\u003e \u003cem\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-p\u003c/code\u003e \u003cem\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-c\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.3\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003estop\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-m\u003c/code\u003e \u003ccode\u003es[mart]\u003c/code\u003e | \u003ccode\u003ef[ast]\u003c/code\u003e | \u003ccode\u003ei[mmediate]\u003c/code\u003e ] [\u003ccode\u003e-W\u003c/code\u003e] [\u003ccode\u003e-t\u003c/code\u003e \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.4\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003erestart\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-m\u003c/code\u003e \u003ccode\u003es[mart]\u003c/code\u003e | \u003ccode\u003ef[ast]\u003c/code\u003e | \u003ccode\u003ei[mmediate]\u003c/code\u003e ] [\u003ccode\u003e-W\u003c/code\u003e] [\u003ccode\u003e-t\u003c/code\u003e \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-s\u003c/code\u003e] [\u003ccode\u003e-o\u003c/code\u003e \u003cem\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-c\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.5\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003ereload\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.6\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003estatus\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.7\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003epromote\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-W\u003c/code\u003e] [\u003ccode\u003e-t\u003c/code\u003e \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.8\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003elogrotate\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.9\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003ekill\u003c/code\u003e \u003cem\u003e\u003ccode\u003esignal_name\u003c/code\u003e\u003c/em\u003e \u003cem\u003e\u003ccode\u003eprocess_id\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eOn Microsoft Windows, also:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.11\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003eregister\u003c/code\u003e [\u003ccode\u003e-D\u003c/code\u003e \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-N\u003c/code\u003e \u003cem\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-U\u003c/code\u003e \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-P\u003c/code\u003e \u003cem\u003e\u003ccode\u003epassword\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-S\u003c/code\u003e \u003ccode\u003ea[uto]\u003c/code\u003e | \u003ccode\u003ed[emand]\u003c/code\u003e ] [\u003ccode\u003e-e\u003c/code\u003e \u003cem\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-W\u003c/code\u003e] [\u003ccode\u003e-t\u003c/code\u003e \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode\u003e-s\u003c/code\u003e] [\u003ccode\u003e-o\u003c/code\u003e \u003cem\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.5.8.4.12\"\u003e\u003ccode\u003epg_ctl\u003c/code\u003e \u003ccode\u003eunregister\u003c/code\u003e [\u003ccode\u003e-N\u003c/code\u003e \u003cem\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PG-CTL-DESCRIPTION\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epg_ctl\u003c/span\u003e is a utility for initializing a \u003cspan\u003ePostgreSQL\u003c/span\u003e database cluster, starting, stopping, or restarting the \u003cspan\u003ePostgreSQL\u003c/span\u003e database server (\u003ca href=\"/docs/18/app-postgres.html\" title=\"postgres\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e), or displaying the status of a running server. Although the server can be started manually, \u003cspan\u003epg_ctl\u003c/span\u003e encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003einit\u003c/code\u003e or \u003ccode\u003einitdb\u003c/code\u003e mode creates a new \u003cspan\u003ePostgreSQL\u003c/span\u003e database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the \u003ccode\u003einitdb\u003c/code\u003e command. See \u003ca href=\"/docs/18/app-initdb.html\" title=\"initdb\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e for details.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003estart\u003c/code\u003e mode launches a new server. The server is started in the background, and its standard input is attached to \u003ccode\u003e/dev/null\u003c/code\u003e (or \u003ccode\u003enul\u003c/code\u003e on Windows). On Unix-like systems, by default, the server\u0026#39;s standard output and standard error are sent to \u003cspan\u003epg_ctl\u003c/span\u003e\u0026#39;s standard output (not standard error). The standard output of \u003cspan\u003epg_ctl\u003c/span\u003e should then be redirected to a file or piped to another process such as a log rotating program like \u003cspan\u003erotatelogs\u003c/span\u003e; otherwise \u003ccode\u003epostgres\u003c/code\u003e will write its output to the controlling terminal (from the background) and will not leave the shell\u0026#39;s process group. On Windows, by default the server\u0026#39;s standard output and standard error are sent to the terminal. These default behaviors can be changed by using \u003ccode\u003e-l\u003c/code\u003e to append the server\u0026#39;s output to a log file. Use of either \u003ccode\u003e-l\u003c/code\u003e or output redirection is recommended.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003estop\u003c/code\u003e mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the \u003ccode\u003e-m\u003c/code\u003e option. \u003cspan\u003e“\u003cspan\u003eSmart\u003c/span\u003e”\u003c/span\u003e mode disallows new connections, then waits for all existing clients to disconnect. If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. \u003cspan\u003e“\u003cspan\u003eFast\u003c/span\u003e”\u003c/span\u003e mode (the default) does not wait for clients to disconnect. All active transactions are rolled back and clients are forcibly disconnected, then the server is shut down. \u003cspan\u003e“\u003cspan\u003eImmediate\u003c/span\u003e”\u003c/span\u003e mode will abort all server processes immediately, without a clean shutdown. This choice will lead to a crash-recovery cycle during the next server start.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003erestart\u003c/code\u003e mode effectively executes a stop followed by a start. This allows changing the \u003ccode\u003epostgres\u003c/code\u003e command-line options, or changing configuration-file options that cannot be changed without restarting the server. If relative paths were used on the command line during server start, \u003ccode\u003erestart\u003c/code\u003e might fail unless \u003cspan\u003epg_ctl\u003c/span\u003e is executed in the same current directory as it was during server start.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ereload\u003c/code\u003e mode simply sends the \u003ccode\u003epostgres\u003c/code\u003e server process a \u003cspan\u003eSIGHUP\u003c/span\u003e signal, causing it to reread its configuration files (\u003ccode\u003epostgresql.conf\u003c/code\u003e, \u003ccode\u003epg_hba.conf\u003c/code\u003e, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003estatus\u003c/code\u003e mode checks whether a server is running in the specified data directory. If it is, the server\u0026#39;s PID and the command line options that were used to invoke it are displayed. If the server is not running, \u003cspan\u003epg_ctl\u003c/span\u003e returns an exit status of 3. If an accessible data directory is not specified, \u003cspan\u003epg_ctl\u003c/span\u003e returns an exit status of 4.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003epromote\u003c/code\u003e mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003elogrotate\u003c/code\u003e mode rotates the server log file. For details on how to use this mode with external log rotation tools, see \u003ca href=\"/docs/18/logfile-maintenance.html\" rel=\"nofollow\"\u003eSection 24.3\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003ekill\u003c/code\u003e mode sends a signal to a specified process. This is primarily valuable on \u003cspan\u003eMicrosoft Windows\u003c/span\u003e which does not have a built-in \u003cspan\u003ekill\u003c/span\u003e command. Use \u003ccode\u003e--help\u003c/code\u003e to see a list of supported signal names.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eregister\u003c/code\u003e mode registers the \u003cspan\u003ePostgreSQL\u003c/span\u003e server as a system service on \u003cspan\u003eMicrosoft Windows\u003c/span\u003e. The \u003ccode\u003e-S\u003c/code\u003e option allows selection of service start type, either \u003cspan\u003e“\u003cspan\u003eauto\u003c/span\u003e”\u003c/span\u003e (start service automatically on system startup) or \u003cspan\u003e“\u003cspan\u003edemand\u003c/span\u003e”\u003c/span\u003e (start service on demand).\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003eunregister\u003c/code\u003e mode unregisters a system service on \u003cspan\u003eMicrosoft Windows\u003c/span\u003e. This undoes the effects of the \u003ccode\u003eregister\u003c/code\u003e command.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PG-CTL-OPTIONS\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-c\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--core-files\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAttempt to allow server crashes to produce core files, on platforms where this is possible, by lifting any soft resource limit placed on core files. This is useful in debugging or diagnosing problems by allowing a stack trace to be obtained from a failed server process.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-D \u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--pgdata=\u003cem\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the file system location of the database configuration files. If this option is omitted, the environment variable \u003ccode\u003ePGDATA\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-l \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--log=\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAppend the server log output to \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. If the file does not exist, it is created. By default, only the cluster owner can access the log file. If group access is enabled in the cluster, users in the same group as the cluster owner can also read it.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-m \u003cem\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--mode=\u003cem\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the shutdown mode. \u003cem\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e can be \u003ccode\u003esmart\u003c/code\u003e, \u003ccode\u003efast\u003c/code\u003e, or \u003ccode\u003eimmediate\u003c/code\u003e, or the first letter of one of these three. If this option is omitted, \u003ccode\u003efast\u003c/code\u003e is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-o \u003cem\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--options=\u003cem\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be passed directly to the \u003ccode\u003epostgres\u003c/code\u003e command. \u003ccode\u003e-o\u003c/code\u003e can be specified multiple times, with all the given options being passed through.\u003c/p\u003e\n\u003cp\u003eThe \u003cem\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e should usually be surrounded by single or double quotes to ensure that they are passed through as a group.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-o \u003cem\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--options=\u003cem\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be passed directly to the \u003ccode\u003einitdb\u003c/code\u003e command. \u003ccode\u003e-o\u003c/code\u003e can be specified multiple times, with all the given options being passed through.\u003c/p\u003e\n\u003cp\u003eThe \u003cem\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e should usually be surrounded by single or double quotes to ensure that they are passed through as a group.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-p \u003cem\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the \u003ccode\u003epostgres\u003c/code\u003e executable. By default the \u003ccode\u003epostgres\u003c/code\u003e executable is taken from the same directory as \u003ccode\u003epg_ctl\u003c/code\u003e, 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 \u003ccode\u003epostgres\u003c/code\u003e executable was not found.\u003c/p\u003e\n\u003cp\u003eIn \u003ccode\u003einit\u003c/code\u003e mode, this option analogously specifies the location of the \u003ccode\u003einitdb\u003c/code\u003e executable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--silent\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint only errors, no informational messages.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-t \u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--timeout=\u003cem\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the maximum number of seconds to wait when waiting for an operation to complete (see option \u003ccode\u003e-w\u003c/code\u003e). Defaults to the value of the \u003ccode\u003ePGCTLTIMEOUT\u003c/code\u003e environment variable or, if not set, to 60 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan\u003epg_ctl\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--wait\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWait for the operation to complete. This is supported for the modes \u003ccode\u003estart\u003c/code\u003e, \u003ccode\u003estop\u003c/code\u003e, \u003ccode\u003erestart\u003c/code\u003e, \u003ccode\u003epromote\u003c/code\u003e, and \u003ccode\u003eregister\u003c/code\u003e, and is the default for those modes.\u003c/p\u003e\n\u003cp\u003eWhen waiting, \u003ccode\u003epg_ctl\u003c/code\u003e repeatedly checks the server\u0026#39;s PID file, sleeping for a short amount of time between checks. Startup is considered complete when the PID file indicates that the server is ready to accept connections. Shutdown is considered complete when the server removes the PID file. \u003ccode\u003epg_ctl\u003c/code\u003e returns an exit code based on the success of the startup or shutdown.\u003c/p\u003e\n\u003cp\u003eIf the operation does not complete within the timeout (see option \u003ccode\u003e-t\u003c/code\u003e), then \u003ccode\u003epg_ctl\u003c/code\u003e exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-wait\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not wait for the operation to complete. This is the opposite of the option \u003ccode\u003e-w\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf waiting is disabled, the requested action is triggered, but there is no feedback about its success. In that case, the server log file or an external monitoring system would have to be used to check the progress and success of the operation.\u003c/p\u003e\n\u003cp\u003eIn prior releases of PostgreSQL, this was the default except for the \u003ccode\u003estop\u003c/code\u003e mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan\u003epg_ctl\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eIf an option is specified that is valid, but not relevant to the selected operating mode, \u003cspan\u003epg_ctl\u003c/span\u003e ignores it.\u003c/p\u003e\n\u003cdiv id=\"APP-PG-CTL-WINDOWS-OPTIONS\"\u003e\n\u003ch3\u003eOptions for Windows\u003c/h3\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-e \u003cem\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eName of the event source for \u003cspan\u003epg_ctl\u003c/span\u003e to use for logging to the event log when running as a Windows service. The default is \u003ccode\u003ePostgreSQL\u003c/code\u003e. Note that this only controls messages sent from \u003cspan\u003epg_ctl\u003c/span\u003e itself; once started, the server will use the event source specified by its \u003ca href=\"/docs/18/runtime-config-logging.html#GUC-EVENT-SOURCE\" rel=\"nofollow\"\u003eevent_source\u003c/a\u003e parameter. Should the server fail very early in startup, before that parameter has been set, it might also log using the default event source name \u003ccode\u003ePostgreSQL\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-N \u003cem\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eName of the system service to register. This name will be used as both the service name and the display name. The default is \u003ccode\u003ePostgreSQL\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-P \u003cem\u003e\u003ccode\u003epassword\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePassword for the user to run the service as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-S \u003cem\u003e\u003ccode\u003estart-type\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStart type of the system service. \u003cem\u003e\u003ccode\u003estart-type\u003c/code\u003e\u003c/em\u003e can be \u003ccode\u003eauto\u003c/code\u003e, or \u003ccode\u003edemand\u003c/code\u003e, or the first letter of one of these two. If this option is omitted, \u003ccode\u003eauto\u003c/code\u003e is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-U \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUser name for the user to run the service as. For domain users, use the format \u003ccode\u003eDOMAIN\\username\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.8.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ePGCTLTIMEOUT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault limit on the number of seconds to wait when waiting for startup or shutdown to complete. If not set, the default is 60 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ePGDATA\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault data directory location.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eMost \u003ccode\u003epg_ctl\u003c/code\u003e modes require knowing the data directory location; therefore, the \u003ccode\u003e-D\u003c/code\u003e option is required unless \u003ccode\u003ePGDATA\u003c/code\u003e is set.\u003c/p\u003e\n\u003cp\u003eFor additional variables that affect the server, see \u003ca href=\"/docs/18/app-postgres.html\" title=\"postgres\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.8.8\"\u003e\n\u003ch2\u003eFiles\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003epostmaster.pid\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003cspan\u003epg_ctl\u003c/span\u003e examines this file in the data directory to determine whether the server is currently running.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003epostmaster.opts\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this file exists in the data directory, \u003cspan\u003epg_ctl\u003c/span\u003e (in \u003ccode\u003erestart\u003c/code\u003e mode) will pass the contents of the file as options to \u003cspan\u003epostgres\u003c/span\u003e, unless overridden by the \u003ccode\u003e-o\u003c/code\u003e option. The contents of this file are also displayed in \u003ccode\u003estatus\u003c/code\u003e mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"R1-APP-PGCTL-2\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cdiv id=\"R2-APP-PGCTL-3\"\u003e\n\u003ch3\u003eStarting the Server\u003c/h3\u003e\n\u003cp\u003eTo start the server, waiting until the server is accepting connections:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_ctl start\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo start the server using port 5433, and running without \u003ccode\u003efsync\u003c/code\u003e, use:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_ctl -o \u0026#34;-F -p 5433\u0026#34; start\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv id=\"R2-APP-PGCTL-4\"\u003e\n\u003ch3\u003eStopping the Server\u003c/h3\u003e\n\u003cp\u003eTo stop the server, use:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_ctl stop\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eThe \u003ccode\u003e-m\u003c/code\u003e option allows control over \u003cspan\u003e\u003cem\u003ehow\u003c/em\u003e\u003c/span\u003e the server shuts down:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_ctl stop -m smart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv id=\"R2-APP-PGCTL-5\"\u003e\n\u003ch3\u003eRestarting the Server\u003c/h3\u003e\n\u003cp\u003eRestarting the server is almost equivalent to stopping the server and starting it again, except that by default, \u003ccode\u003epg_ctl\u003c/code\u003e saves and reuses the command line options that were passed to the previously-running instance. To restart the server using the same options as before, use:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_ctl restart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eBut if \u003ccode\u003e-o\u003c/code\u003e is specified, that replaces any previous options. To restart using port 5433, disabling \u003ccode\u003efsync\u003c/code\u003e upon restart:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_ctl -o \u0026#34;-F -p 5433\u0026#34; restart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv id=\"R2-APP-PGCTL-6\"\u003e\n\u003ch3\u003eShowing the Server Status\u003c/h3\u003e\n\u003cp\u003eHere is sample status output from \u003cspan\u003epg_ctl\u003c/span\u003e:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_ctl status\u003c/code\u003e\u003c/strong\u003e\n\u003ccode\u003e\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \u0026#34;-D\u0026#34; \u0026#34;/usr/local/pgsql/data\u0026#34; \u0026#34;-p\u0026#34; \u0026#34;5433\u0026#34; \u0026#34;-B\u0026#34; \u0026#34;128\u0026#34;\n\u003c/code\u003e\n\u003c/pre\u003e\n\u003cp\u003eThe second line is the command that would be invoked in restart mode.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.5.8.10\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/docs/18/app-initdb.html\" title=\"initdb\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/docs/18/app-postgres.html\" title=\"postgres\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"5470aeaffd7749ae39c5ee278070f7749fe0e54575205315620f6293bb094a7b","Payload":{"description":["pg_ctl — initialize, start, stop, or control a PostgreSQL server"],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PG-CTL\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_ctl — initialize, start, stop, or control a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.1\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003einit[db]\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-o\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.2\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003estart\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-l\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-o\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-p\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-c\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.3\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003estop\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-m\u003c/code\u003e \u003ccode class=\"option\"\u003es[mart]\u003c/code\u003e | \u003ccode class=\"option\"\u003ef[ast]\u003c/code\u003e | \u003ccode class=\"option\"\u003ei[mmediate]\u003c/code\u003e ] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.4\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003erestart\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-m\u003c/code\u003e \u003ccode class=\"option\"\u003es[mart]\u003c/code\u003e | \u003ccode class=\"option\"\u003ef[ast]\u003c/code\u003e | \u003ccode class=\"option\"\u003ei[mmediate]\u003c/code\u003e ] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-o\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-c\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.5\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003ereload\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.6\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003estatus\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.7\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003epromote\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.8\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003elogrotate\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.9\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003ekill\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esignal_name\u003c/code\u003e\u003c/em\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eprocess_id\u003c/code\u003e\u003c/em\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cp\u003eOn Microsoft Windows, also:\u003c/p\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.11\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003eregister\u003c/code\u003e [\u003ccode class=\"option\"\u003e-D\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-N\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-U\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-P\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003epassword\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-S\u003c/code\u003e \u003ccode class=\"option\"\u003ea[uto]\u003c/code\u003e | \u003ccode class=\"option\"\u003ed[emand]\u003c/code\u003e ] [\u003ccode class=\"option\"\u003e-e\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-W\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-t\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e] [\u003ccode class=\"option\"\u003e-s\u003c/code\u003e] [\u003ccode class=\"option\"\u003e-o\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.5.8.4.12\"\u003e\u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e \u003ccode class=\"option\"\u003eunregister\u003c/code\u003e [\u003ccode class=\"option\"\u003e-N\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e is a utility for initializing a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster, starting, stopping, or restarting the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database server (\u003ca class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e), or displaying the status of a running server. Although the server can be started manually, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"option\"\u003einit\u003c/code\u003e or \u003ccode class=\"option\"\u003einitdb\u003c/code\u003e mode creates a new \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e command. See \u003ca class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e for details.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003estart\u003c/code\u003e mode launches a new server. The server is started in the background, and its standard input is attached to \u003ccode class=\"filename\"\u003e/dev/null\u003c/code\u003e (or \u003ccode class=\"literal\"\u003enul\u003c/code\u003e on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e's standard output (not standard error). The standard output of \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e should then be redirected to a file or piped to another process such as a log rotating program like \u003cspan class=\"application\"\u003erotatelogs\u003c/span\u003e; otherwise \u003ccode class=\"command\"\u003epostgres\u003c/code\u003e will write its output to the controlling terminal (from the background) and will not leave the shell's process group. On Windows, by default the server's standard output and standard error are sent to the terminal. These default behaviors can be changed by using \u003ccode class=\"option\"\u003e-l\u003c/code\u003e to append the server's output to a log file. Use of either \u003ccode class=\"option\"\u003e-l\u003c/code\u003e or output redirection is recommended.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003estop\u003c/code\u003e mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the \u003ccode class=\"option\"\u003e-m\u003c/code\u003e option. \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eSmart\u003c/span\u003e”\u003c/span\u003e mode disallows new connections, then waits for all existing clients to disconnect. If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eFast\u003c/span\u003e”\u003c/span\u003e mode (the default) does not wait for clients to disconnect. All active transactions are rolled back and clients are forcibly disconnected, then the server is shut down. \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eImmediate\u003c/span\u003e”\u003c/span\u003e mode will abort all server processes immediately, without a clean shutdown. This choice will lead to a crash-recovery cycle during the next server start.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003erestart\u003c/code\u003e mode effectively executes a stop followed by a start. This allows changing the \u003ccode class=\"command\"\u003epostgres\u003c/code\u003e command-line options, or changing configuration-file options that cannot be changed without restarting the server. If relative paths were used on the command line during server start, \u003ccode class=\"option\"\u003erestart\u003c/code\u003e might fail unless \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e is executed in the same current directory as it was during server start.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003ereload\u003c/code\u003e mode simply sends the \u003ccode class=\"command\"\u003epostgres\u003c/code\u003e server process a \u003cspan class=\"systemitem\"\u003eSIGHUP\u003c/span\u003e signal, causing it to reread its configuration files (\u003ccode class=\"filename\"\u003epostgresql.conf\u003c/code\u003e, \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003estatus\u003c/code\u003e mode checks whether a server is running in the specified data directory. If it is, the server's PID and the command line options that were used to invoke it are displayed. If the server is not running, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e returns an exit status of 3. If an accessible data directory is not specified, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e returns an exit status of 4.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003epromote\u003c/code\u003e mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003elogrotate\u003c/code\u003e mode rotates the server log file. For details on how to use this mode with external log rotation tools, see \u003ca class=\"xref\" href=\"/docs/18/logfile-maintenance.html\" title=\"24.3. Log File Maintenance\"\u003eSection 24.3\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003ekill\u003c/code\u003e mode sends a signal to a specified process. This is primarily valuable on \u003cspan class=\"productname\"\u003eMicrosoft Windows\u003c/span\u003e which does not have a built-in \u003cspan class=\"application\"\u003ekill\u003c/span\u003e command. Use \u003ccode class=\"literal\"\u003e--help\u003c/code\u003e to see a list of supported signal names.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003eregister\u003c/code\u003e mode registers the \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e server as a system service on \u003cspan class=\"productname\"\u003eMicrosoft Windows\u003c/span\u003e. The \u003ccode class=\"option\"\u003e-S\u003c/code\u003e option allows selection of service start type, either \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eauto\u003c/span\u003e”\u003c/span\u003e (start service automatically on system startup) or \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edemand\u003c/span\u003e”\u003c/span\u003e (start service on demand).\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003eunregister\u003c/code\u003e mode unregisters a system service on \u003cspan class=\"productname\"\u003eMicrosoft Windows\u003c/span\u003e. This undoes the effects of the \u003ccode class=\"option\"\u003eregister\u003c/code\u003e command.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--core-files\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAttempt to allow server crashes to produce core files, on platforms where this is possible, by lifting any soft resource limit placed on core files. This is useful in debugging or diagnosing problems by allowing a stack trace to be obtained from a failed server process.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edatadir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the file system location of the database configuration files. If this option is omitted, the environment variable \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--log=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eAppend the server log output to \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e. If the file does not exist, it is created. By default, only the cluster owner can access the log file. If group access is enabled in the cluster, users in the same group as the cluster owner can also read it.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-m \u003cem class=\"replaceable\"\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--mode=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the shutdown mode. \u003cem class=\"replaceable\"\u003e\u003ccode\u003emode\u003c/code\u003e\u003c/em\u003e can be \u003ccode class=\"literal\"\u003esmart\u003c/code\u003e, \u003ccode class=\"literal\"\u003efast\u003c/code\u003e, or \u003ccode class=\"literal\"\u003eimmediate\u003c/code\u003e, or the first letter of one of these three. If this option is omitted, \u003ccode class=\"literal\"\u003efast\u003c/code\u003e is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--options=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be passed directly to the \u003ccode class=\"command\"\u003epostgres\u003c/code\u003e command. \u003ccode class=\"option\"\u003e-o\u003c/code\u003e can be specified multiple times, with all the given options being passed through.\u003c/p\u003e\n\u003cp\u003eThe \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoptions\u003c/code\u003e\u003c/em\u003e should usually be surrounded by single or double quotes to ensure that they are passed through as a group.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-o \u003cem class=\"replaceable\"\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--options=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies options to be passed directly to the \u003ccode class=\"command\"\u003einitdb\u003c/code\u003e command. \u003ccode class=\"option\"\u003e-o\u003c/code\u003e can be specified multiple times, with all the given options being passed through.\u003c/p\u003e\n\u003cp\u003eThe \u003cem class=\"replaceable\"\u003e\u003ccode\u003einitdb-options\u003c/code\u003e\u003c/em\u003e should usually be surrounded by single or double quotes to ensure that they are passed through as a group.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003epath\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the \u003ccode class=\"filename\"\u003epostgres\u003c/code\u003e executable. By default the \u003ccode class=\"filename\"\u003epostgres\u003c/code\u003e executable is taken from the same directory as \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e, 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 \u003ccode class=\"filename\"\u003epostgres\u003c/code\u003e executable was not found.\u003c/p\u003e\n\u003cp\u003eIn \u003ccode class=\"literal\"\u003einit\u003c/code\u003e mode, this option analogously specifies the location of the \u003ccode class=\"filename\"\u003einitdb\u003c/code\u003e executable.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--silent\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint only errors, no informational messages.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t \u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--timeout=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eseconds\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the maximum number of seconds to wait when waiting for an operation to complete (see option \u003ccode class=\"option\"\u003e-w\u003c/code\u003e). Defaults to the value of the \u003ccode class=\"envar\"\u003ePGCTLTIMEOUT\u003c/code\u003e environment variable or, if not set, to 60 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wait\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWait for the operation to complete. This is supported for the modes \u003ccode class=\"literal\"\u003estart\u003c/code\u003e, \u003ccode class=\"literal\"\u003estop\u003c/code\u003e, \u003ccode class=\"literal\"\u003erestart\u003c/code\u003e, \u003ccode class=\"literal\"\u003epromote\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eregister\u003c/code\u003e, and is the default for those modes.\u003c/p\u003e\n\u003cp\u003eWhen waiting, \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e repeatedly checks the server's PID file, sleeping for a short amount of time between checks. Startup is considered complete when the PID file indicates that the server is ready to accept connections. Shutdown is considered complete when the server removes the PID file. \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e returns an exit code based on the success of the startup or shutdown.\u003c/p\u003e\n\u003cp\u003eIf the operation does not complete within the timeout (see option \u003ccode class=\"option\"\u003e-t\u003c/code\u003e), then \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-wait\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not wait for the operation to complete. This is the opposite of the option \u003ccode class=\"option\"\u003e-w\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf waiting is disabled, the requested action is triggered, but there is no feedback about its success. In that case, the server log file or an external monitoring system would have to be used to check the progress and success of the operation.\u003c/p\u003e\n\u003cp\u003eIn prior releases of PostgreSQL, this was the default except for the \u003ccode class=\"literal\"\u003estop\u003c/code\u003e mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eIf an option is specified that is valid, but not relevant to the selected operating mode, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e ignores it.\u003c/p\u003e\n\u003cdiv class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\"\u003e\n\u003ch3\u003eOptions for Windows\u003c/h3\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e \u003cem class=\"replaceable\"\u003e\u003ccode\u003esource\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eName of the event source for \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e to use for logging to the event log when running as a Windows service. The default is \u003ccode class=\"literal\"\u003ePostgreSQL\u003c/code\u003e. Note that this only controls messages sent from \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e itself; once started, the server will use the event source specified by its \u003ca class=\"xref\" href=\"/docs/18/runtime-config-logging.html#GUC-EVENT-SOURCE\"\u003eevent_source\u003c/a\u003e parameter. Should the server fail very early in startup, before that parameter has been set, it might also log using the default event source name \u003ccode class=\"literal\"\u003ePostgreSQL\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N \u003cem class=\"replaceable\"\u003e\u003ccode\u003eservicename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eName of the system service to register. This name will be used as both the service name and the display name. The default is \u003ccode class=\"literal\"\u003ePostgreSQL\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P \u003cem class=\"replaceable\"\u003e\u003ccode\u003epassword\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePassword for the user to run the service as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003estart-type\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStart type of the system service. \u003cem class=\"replaceable\"\u003e\u003ccode\u003estart-type\u003c/code\u003e\u003c/em\u003e can be \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e, or \u003ccode class=\"literal\"\u003edemand\u003c/code\u003e, or the first letter of one of these two. If this option is omitted, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUser name for the user to run the service as. For domain users, use the format \u003ccode class=\"literal\"\u003eDOMAIN\\username\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.8.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGCTLTIMEOUT\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault limit on the number of seconds to wait when waiting for startup or shutdown to complete. If not set, the default is 60 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDefault data directory location.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eMost \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e modes require knowing the data directory location; therefore, the \u003ccode class=\"option\"\u003e-D\u003c/code\u003e option is required unless \u003ccode class=\"envar\"\u003ePGDATA\u003c/code\u003e is set.\u003c/p\u003e\n\u003cp\u003eFor additional variables that affect the server, see \u003ca class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.8.8\"\u003e\n\u003ch2\u003eFiles\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"filename\"\u003epostmaster.pid\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e examines this file in the data directory to determine whether the server is currently running.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"filename\"\u003epostmaster.opts\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIf this file exists in the data directory, \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e (in \u003ccode class=\"option\"\u003erestart\u003c/code\u003e mode) will pass the contents of the file as options to \u003cspan class=\"application\"\u003epostgres\u003c/span\u003e, unless overridden by the \u003ccode class=\"option\"\u003e-o\u003c/code\u003e option. The contents of this file are also displayed in \u003ccode class=\"option\"\u003estatus\u003c/code\u003e mode.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"R1-APP-PGCTL-2\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PGCTL-3\"\u003e\n\u003ch3\u003eStarting the Server\u003c/h3\u003e\n\u003cp\u003eTo start the server, waiting until the server is accepting connections:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl start\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo start the server using port 5433, and running without \u003ccode class=\"function\"\u003efsync\u003c/code\u003e, use:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl -o \"-F -p 5433\" start\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PGCTL-4\"\u003e\n\u003ch3\u003eStopping the Server\u003c/h3\u003e\n\u003cp\u003eTo stop the server, use:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl stop\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eThe \u003ccode class=\"option\"\u003e-m\u003c/code\u003e option allows control over \u003cspan class=\"emphasis\"\u003e\u003cem\u003ehow\u003c/em\u003e\u003c/span\u003e the server shuts down:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl stop -m smart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PGCTL-5\"\u003e\n\u003ch3\u003eRestarting the Server\u003c/h3\u003e\n\u003cp\u003eRestarting the server is almost equivalent to stopping the server and starting it again, except that by default, \u003ccode class=\"command\"\u003epg_ctl\u003c/code\u003e saves and reuses the command line options that were passed to the previously-running instance. To restart the server using the same options as before, use:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl restart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eBut if \u003ccode class=\"option\"\u003e-o\u003c/code\u003e is specified, that replaces any previous options. To restart using port 5433, disabling \u003ccode class=\"function\"\u003efsync\u003c/code\u003e upon restart:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl -o \"-F -p 5433\" restart\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect2\" id=\"R2-APP-PGCTL-6\"\u003e\n\u003ch3\u003eShowing the Server Status\u003c/h3\u003e\n\u003cp\u003eHere is sample status output from \u003cspan class=\"application\"\u003epg_ctl\u003c/span\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_ctl status\u003c/code\u003e\u003c/strong\u003e\n\u003ccode class=\"computeroutput\"\u003e\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n\u003c/code\u003e\n\u003c/pre\u003e\n\u003cp\u003eThe second line is the command that would be invoked in restart mode.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.5.8.10\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003einitdb\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epostgres\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","related":[],"sections":[],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-c --core-files","url":"/docs/18/app-pg-ctl.html"},"summary":"Attempt to allow server crashes to produce core files, on platforms where this is possible, by lifting any soft resource limit placed on core files. This is useful in debugging or diagnosing problems by allowing a stack trace to be obtained from a failed server process."},{"signature":{"text":"-D datadir --pgdata= datadir","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."},{"signature":{"text":"-l filename --log= filename","url":"/docs/18/app-pg-ctl.html"},"summary":"Append the server log output to filename . If the file does not exist, it is created. By default, only the cluster owner can access the log file. If group access is enabled in the cluster, users in the same group as the cluster owner can also read it."},{"signature":{"text":"-m mode --mode= mode","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies the shutdown mode. mode can be smart , fast , or immediate , or the first letter of one of these three. If this option is omitted, fast is the default."},{"signature":{"text":"-o options --options= options","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies options to be passed directly to the postgres command. -o can be specified multiple times, with all the given options being passed through."},{"signature":{"text":"-o initdb-options --options= initdb-options","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies options to be passed directly to the initdb command. -o can be specified multiple times, with all the given options being passed through."},{"signature":{"text":"-p path","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies the location of the postgres executable. By default the postgres executable 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 postgres executable was not found."},{"signature":{"text":"-s --silent","url":"/docs/18/app-pg-ctl.html"},"summary":"Print only errors, no informational messages."},{"signature":{"text":"-t seconds --timeout= seconds","url":"/docs/18/app-pg-ctl.html"},"summary":"Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option -w ). Defaults to the value of the PGCTLTIMEOUT environment variable or, if not set, to 60 seconds."},{"signature":{"text":"-V --version","url":"/docs/18/app-pg-ctl.html"},"summary":"Print the pg_ctl version and exit."},{"signature":{"text":"-w --wait","url":"/docs/18/app-pg-ctl.html"},"summary":"Wait for the operation to complete. This is supported for the modes start , stop , restart , promote , and register , and is the default for those modes."},{"signature":{"text":"-W --no-wait","url":"/docs/18/app-pg-ctl.html"},"summary":"Do not wait for the operation to complete. This is the opposite of the option -w ."},{"signature":{"text":"-? --help","url":"/docs/18/app-pg-ctl.html"},"summary":"Show help about pg_ctl command line arguments, and exit."},{"signature":{"text":"-e source","url":"/docs/18/app-pg-ctl.html"},"summary":"Name of the event source for pg_ctl to use for logging to the event log when running as a Windows service. The default is PostgreSQL . Note that this only controls messages sent from pg_ctl itself; once started, the server will use the event source specified by its event_source parameter. Should the server fail very early in startup, before that parameter has been set, it might also log using the default event source name PostgreSQL ."},{"signature":{"text":"-N servicename","url":"/docs/18/app-pg-ctl.html"},"summary":"Name of the system service to register. This name will be used as both the service name and the display name. The default is PostgreSQL ."},{"signature":{"text":"-P password","url":"/docs/18/app-pg-ctl.html"},"summary":"Password for the user to run the service as."},{"signature":{"text":"-S start-type","url":"/docs/18/app-pg-ctl.html"},"summary":"Start type of the system service. start-type can be auto , or demand , or the first letter of one of these two. If this option is omitted, auto is the default."},{"signature":{"text":"-U username","url":"/docs/18/app-pg-ctl.html"},"summary":"User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Default limit on the number of seconds to wait when waiting for startup or shutdown to complete. If not set, the default is 60 seconds.","name":"PGCTLTIMEOUT"},{"description":"Default data directory location.","name":"PGDATA"}],"title":"Environment variables"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
