{"kind": "tool", "major": "18", "item": {"slug": "pg-ctl", "name": "pg_ctl", "name_zh": "", "category": "Server applications", "summary": "pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server", "aliases": ["pg_ctl"], "content_hash": "5aadba1119910e63d661fae71ee80b57a239eb75b5fe35d3764c71d85dda2db3", "versions": {"10": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "10.23"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/10/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"summary": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.", "signature": {"url": "/docs/10/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/10/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/10/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/10/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/10/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/10/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/10/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/10/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/10/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "summary": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.", "signature": "-l filename --log= filename", "source_url": "/docs/10/app-pg-ctl.html", "description": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default."}, {"names": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/10/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/10/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/10/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/10/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/10/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/10/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/10/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/10/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "label": "10.23", "major": "10", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/10/postgresql-10-A4.pdf", "bytes": 12631706, "pages": 2591, "sha256": "34497ab9efb45c5bdf1bd11b9016b5451354feb462fa029cf74557a5fa5fbbc1", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/10/postgresql-10-US.pdf", "bytes": 12531684, "pages": 2724, "sha256": "429cc7133ddf4f97c560aa466dc9caea4b718721a8321e293357037cf0af4733", "built_at": "2026-09-26"}}, "tree": "10", "index": "index.html", "major": "10", "pages": 1085, "release": "10.23", "source_url": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea", "evidence_kind": "English manual and source declarations", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "sources": [{"url": "/docs/10/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "10.23 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "d88723e16a11c3f2c60fbfe7d1a9ef9f6d0604e59babf639e24ced73d1fd0b14"}, {"url": "/docs/10/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "2a6043b88501763a31348758a370a42cd7f9a179c7fdf3ef0e353c82e95b33e9"}], "sections": [], "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 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 ]"], "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 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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.10\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/10/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/10/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> mode disallows new connections, then waits for all existing clients to disconnect and any online backup to finish. If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> mode (the default) does not wait for clients to disconnect and will terminate an online backup in progress. All active transactions are rolled back and clients are forcibly disconnected, then the server is shut down. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. If the file does not exist, it is created. The <span class=\"systemitem\">umask</span> is set to 077, so access to the log file is disallowed to other users by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/10/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.6.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p><code class=\"command\">pg_ctl</code>, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/10/libpq-envars.html\" title=\"33.14.\u00a0Environment Variables\">Section\u00a033.14</a>).</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/10/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.6.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre></div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre></div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre></div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">pg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.6.10\">\n<h2>See Also</h2>\n<span class=\"simplelist\"><a class=\"xref\" href=\"/docs/10/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a>, <a class=\"xref\" href=\"/docs/10/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span></div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "description": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default."}, {"names": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "bdd7be8cf41311fb924c4f72b4b5fe321c871e83c410530b40456e14200769ee"}, "11": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "11.22"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/11/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"summary": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.", "signature": {"url": "/docs/11/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/11/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/11/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/11/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/11/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/11/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/11/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/11/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/11/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "summary": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.", "signature": "-l filename --log= filename", "source_url": "/docs/11/app-pg-ctl.html", "description": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default."}, {"names": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/11/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/11/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/11/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/11/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/11/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/11/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/11/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/11/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "label": "11.22", "major": "11", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/11/postgresql-11-A4.pdf", "bytes": 13057499, "pages": 2732, "sha256": "41d75855e610d0d9b8802b87dc5b080bef8d7e91c7cf69401fbf8d3cf801b4b5", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/11/postgresql-11-US.pdf", "bytes": 12961189, "pages": 2883, "sha256": "6a8899ef36935a5b7ed2b436207564a567a4ef1eb1c2200195876b8de4d4fa30", "built_at": "2026-09-26"}}, "tree": "11", "index": "index.html", "major": "11", "pages": 1125, "release": "11.22", "source_url": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f", "evidence_kind": "English manual and source declarations", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "sources": [{"url": "/docs/11/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "11.22 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "a1a6ede46f1966be3cd3cff5b58cbd973bb3c23de994d80e89c46796199e6fa1"}, {"url": "/docs/11/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e940a8505b6742c717a1683d19bf8f759aad245633a59db9e83a345ae7c5709a"}], "sections": [], "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 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 ]"], "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 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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.10\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.6.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/11/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/11/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> mode disallows new connections, then waits for all existing clients to disconnect and any online backup to finish. If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> mode (the default) does not wait for clients to disconnect and will terminate an online backup in progress. All active transactions are rolled back and clients are forcibly disconnected, then the server is shut down. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. If the file does not exist, it is created. The <span class=\"systemitem\">umask</span> is set to 077, so access to the log file is disallowed to other users by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/11/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.6.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p><code class=\"command\">pg_ctl</code>, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/11/libpq-envars.html\" title=\"34.14.\u00a0Environment Variables\">Section\u00a034.14</a>).</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/11/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.6.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.6.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/11/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a>, <a class=\"xref\" href=\"/docs/11/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "description": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default."}, {"names": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "bdd7be8cf41311fb924c4f72b4b5fe321c871e83c410530b40456e14200769ee"}, "12": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "12.22"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/12/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"summary": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.", "signature": {"url": "/docs/12/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/12/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/12/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/12/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/12/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/12/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/12/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/12/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/12/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "summary": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.", "signature": "-l filename --log= filename", "source_url": "/docs/12/app-pg-ctl.html", "description": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default."}, {"names": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/12/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/12/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/12/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/12/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/12/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/12/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/12/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/12/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "label": "12.22", "major": "12", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/12/postgresql-12-A4.pdf", "bytes": 13424351, "pages": 2803, "sha256": "7422cf53fd1939e7a3d2925231a88b0330e468afa5393627cac0ff86158a0621", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/12/postgresql-12-US.pdf", "bytes": 13322565, "pages": 2958, "sha256": "51f3b04e72907fc38512685946223452ea65f84419c60c66241dfa3396035e77", "built_at": "2026-09-26"}}, "tree": "12", "index": "index.html", "major": "12", "pages": 1131, "release": "12.22", "source_url": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "svg_assets": 2, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4", "evidence_kind": "English manual and source declarations", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "sources": [{"url": "/docs/12/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "12.22 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "0a25d6293cbf22487ae209ce7f50889b2ce03a666fe2f7cf039be0413751f7ee"}, {"url": "/docs/12/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "7f6ae1fadc1b0bffa606551460e62aacdc2508a3fb66566ddae861928ca6080b"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/12/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/12/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> mode disallows new connections, then waits for all existing clients to disconnect and any online backup to finish. If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> mode (the default) does not wait for clients to disconnect and will terminate an online backup in progress. All active transactions are rolled back and clients are forcibly disconnected, then the server is shut down. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/12/logfile-maintenance.html\" title=\"24.3.\u00a0Log File Maintenance\">Section\u00a024.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. If the file does not exist, it is created. The <span class=\"systemitem\">umask</span> is set to 077, so access to the log file is disallowed to other users by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/12/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/12/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/12/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a>, <a class=\"xref\" href=\"/docs/12/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "description": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default."}, {"names": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "f5be1eb0def0d51365d25fd86e3bb235fa77663e2f180400de1c082bc7fca5d5"}, "13": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "13.23"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/13/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"summary": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.", "signature": {"url": "/docs/13/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/13/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/13/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/13/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/13/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/13/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/13/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/13/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/13/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "summary": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.", "signature": "-l filename --log= filename", "source_url": "/docs/13/app-pg-ctl.html", "description": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default."}, {"names": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/13/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/13/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/13/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/13/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/13/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/13/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/13/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/13/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "label": "13.23", "major": "13", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/13/postgresql-13-A4.pdf", "bytes": 13843239, "pages": 2826, "sha256": "171cc09f90936dbc1cbd503a98ff07ae72ea58ab9771ff051313f1217737799c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/13/postgresql-13-US.pdf", "bytes": 13739572, "pages": 2984, "sha256": "48d09c6e197d9db4220f41afe83efe848a8661b1b168d3b89419751ecaf6c24d", "built_at": "2026-09-26"}}, "tree": "13", "index": "index.html", "major": "13", "pages": 1139, "release": "13.23", "source_url": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6", "evidence_kind": "English manual and source declarations", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "sources": [{"url": "/docs/13/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "13.23 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "cf833e187a2a35f6e170f3fa67a0577665b178d0a2be7f8d2817191d7beae8f0"}, {"url": "/docs/13/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "074ef8577fd368272a2360309e1226e2d0b1e570a3e1da62dfcca63ac9ee5539"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/13/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/13/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> mode disallows new connections, then waits for all existing clients to disconnect and any online backup to finish. If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> mode (the default) does not wait for clients to disconnect and will terminate an online backup in progress. All active transactions are rolled back and clients are forcibly disconnected, then the server is shut down. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/13/logfile-maintenance.html\" title=\"24.3.\u00a0Log File Maintenance\">Section\u00a024.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. If the file does not exist, it is created. The <span class=\"systemitem\">umask</span> is set to 077, so access to the log file is disallowed to other users by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/13/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/13/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/13/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\">initdb</span></a>, <a class=\"xref\" href=\"/docs/13/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "description": "Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default."}, {"names": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "f5be1eb0def0d51365d25fd86e3bb235fa77663e2f180400de1c082bc7fca5d5"}, "14": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "14.24"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/14/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/14/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/14/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/14/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/14/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/14/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/14/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/14/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/14/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "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": "-l filename --log= filename", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/14/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/14/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/14/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/14/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/14/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/14/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/14/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/14/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "label": "14.24", "major": "14", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/14/postgresql-14-A4.pdf", "bytes": 14354704, "pages": 2944, "sha256": "8bc6b9dd7b246888bb77f0a5e8c39a2eae52e9926569832669c7d1600becb27c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/14/postgresql-14-US.pdf", "bytes": 14242178, "pages": 3102, "sha256": "b7ecb5a5f62d8b9f73a69e25a7d26ba285373bc53168a553bff7b77955506db4", "built_at": "2026-09-26"}}, "tree": "14", "index": "index.html", "major": "14", "pages": 1158, "release": "14.24", "source_url": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae", "evidence_kind": "English manual and source declarations", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "sources": [{"url": "/docs/14/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "14.24 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "719eb9adfe76c94dbeb3061bfb6f26283d31d560dcb22decef5f9a7bb19a8983"}, {"url": "/docs/14/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "db0cdccaa8d3c65ad3b2a07d4956eb5a783a18505bfa0f9d9626eef4ab94fe44"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/14/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/14/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> mode disallows new connections, then waits for all existing clients to disconnect and any online backup to finish. If the server is in hot standby, recovery and streaming replication will be terminated once all clients have disconnected. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> mode (the default) does not wait for clients to disconnect and will terminate an online backup in progress. All active transactions are rolled back and clients are forcibly disconnected, then the server is shut down. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/14/logfile-maintenance.html\" title=\"25.3.\u00a0Log File Maintenance\">Section\u00a025.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/14/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/14/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/14/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"/docs/14/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "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": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53"}, "15": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "15.19"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/15/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/15/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/15/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/15/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/15/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/15/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/15/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/15/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/15/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "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": "-l filename --log= filename", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/15/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/15/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/15/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/15/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/15/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/15/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/15/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/15/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "label": "15.19", "major": "15", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/15/postgresql-15-A4.pdf", "bytes": 14609140, "pages": 2987, "sha256": "66228564a4d16efb47d6a914085716ecfe22ca1566db56bc7c3d82f790646d72", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/15/postgresql-15-US.pdf", "bytes": 14495690, "pages": 3153, "sha256": "645a498c2390d47a6223ec74770631185807a19c484edb0fc5a295d9f460bc02", "built_at": "2026-09-26"}}, "tree": "15", "index": "index.html", "major": "15", "pages": 1168, "release": "15.19", "source_url": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545", "evidence_kind": "English manual and source declarations", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "sources": [{"url": "/docs/15/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "15.19 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "06c880a0deff33cf232f150015f267db49d206e5283ec704937bc1f9ef5ed7af"}, {"url": "/docs/15/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "1240cfbb13ebfd22aac8d5ae40c62a9015b246f7774bcf0bce97355ce06350a0"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/15/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/15/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/15/logfile-maintenance.html\" title=\"25.3.\u00a0Log File Maintenance\">Section\u00a025.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/15/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/15/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/15/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"/docs/15/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "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": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53"}, "16": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "16.15"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/16/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/16/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/16/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/16/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/16/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/16/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/16/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/16/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/16/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "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": "-l filename --log= filename", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/16/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/16/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/16/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/16/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/16/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/16/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/16/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/16/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "label": "16.15", "major": "16", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/16/postgresql-16-A4.pdf", "bytes": 15282337, "pages": 3055, "sha256": "4bb6c1f63deedac98736d8c4c7bc0fad0ac24e85b07e21ee10411872f06afd06", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/16/postgresql-16-US.pdf", "bytes": 15164148, "pages": 3220, "sha256": "5b6b6166c89991199e144bb0ae34c17a5f29826251dbf19db1abc0df3a3e771b", "built_at": "2026-09-26"}}, "tree": "16", "index": "index.html", "major": "16", "pages": 1169, "release": "16.15", "source_url": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef", "evidence_kind": "English manual and source declarations", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "sources": [{"url": "/docs/16/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "16.15 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "ef2eb74085a1387ed216a22daf82419978388261da34d3046498b4c19f6105b2"}, {"url": "/docs/16/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "8aaa4422eece8f26d84715f855d9d0f7f87b200f8b82898c73c865ee42c2c70f"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.7.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/16/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/16/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/16/logfile-maintenance.html\" title=\"25.3.\u00a0Log File Maintenance\">Section\u00a025.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/16/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/16/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.7.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/16/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"/docs/16/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "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": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53"}, "17": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "17.11"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/17/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/17/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/17/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/17/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/17/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/17/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/17/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/17/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/17/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "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": "-l filename --log= filename", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/17/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/17/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/17/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/17/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/17/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/17/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/17/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/17/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "label": "17.11", "major": "17", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/17/postgresql-17-A4.pdf", "bytes": 15521293, "pages": 3099, "sha256": "1991354df0dc89e70ec39328c28988ef8b19c6a93671dab3893650b63e9f4e36", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/17/postgresql-17-US.pdf", "bytes": 15398150, "pages": 3270, "sha256": "07696c8f38abf31babf22d2db337093936e7c472d2af36d050b000c49bbcf52c", "built_at": "2026-09-26"}}, "tree": "17", "index": "index.html", "major": "17", "pages": 1143, "release": "17.11", "source_url": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487", "evidence_kind": "English manual and source declarations", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "sources": [{"url": "/docs/17/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "17.11 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "7c02a0fadd45ab6bd22afdbb85d9cb316e90e09c15f218899dafa55f611361eb"}, {"url": "/docs/17/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "01f07993ff020684f4c290d17cdafa26fb17ea5c1d476bc3a5efc68bf8ddd9b9"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/17/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/17/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/17/logfile-maintenance.html\" title=\"24.3.\u00a0Log File Maintenance\">Section\u00a024.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/17/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/17/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/17/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"/docs/17/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "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": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53"}, "18": {"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"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/18/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "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": "-l filename --log= filename", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/18/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/18/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/18/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/18/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/18/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/18/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/18/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "/docs/18/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "18.6 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "bf10289e73df34e48912e8612d5df29f8a8145a2250627d8c099ed59eae23339"}, {"url": "/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/18/logfile-maintenance.html\" title=\"24.3.\u00a0Log File Maintenance\">Section\u00a024.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/18/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "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": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53"}, "19": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "19beta4"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/19/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/19/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/19/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/19/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/19/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/19/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/19/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/19/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/19/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "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": "-l filename --log= filename", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/19/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/19/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/19/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/19/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/19/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/19/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/19/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/19/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "label": "19beta4", "major": "19", "channel": "preview", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/19/postgresql-19-A4.pdf", "bytes": 16064841, "pages": 3052, "sha256": "4dd099e4125c591128fc5f3ebd02178dc24781f9e5ae629f96d67c4c8547427b", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/19/postgresql-19-US.pdf", "bytes": 15974616, "pages": 3225, "sha256": "61971fa857f0956d47341a0388fa6af9ae10acf691d4b2fc009007d384b0342b", "built_at": "2026-09-26"}}, "tree": "19", "index": "index.html", "major": "19", "pages": 1155, "release": "19beta4", "source_url": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "svg_assets": 5, "source_mode": "en SGML built with pinned official archive", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "revision": "1bbbbf4133d426f0e4304010688d2984c30fb67df0cc3a61b3e37eb3f6f37833", "evidence_kind": "English manual and source declarations", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "sources": [{"url": "/docs/19/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "19beta4 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "742d34481524110847b1ade573650621ce4b12b1c8d05818145b4fbdc94d8188"}, {"url": "/docs/19/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "425b070323b448b5516d2cb4e9e4ac77efb5d19dd4e8005d0ae1c61db9ec78e6"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/19/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/19/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/19/logfile-maintenance.html\" title=\"24.3.\u00a0Log File Maintenance\">Section\u00a024.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/19/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/19/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/19/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"/docs/19/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "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": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53"}, "20": {"facts": [{"label": "Documented executable", "value": "pg_ctl"}, {"label": "Executable version", "value": "20devel"}, {"label": "Reference inventory", "value": "Server applications"}, {"label": "Option definition groups", "value": "18"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/devel/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/devel/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/devel/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/devel/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/devel/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/devel/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/devel/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/devel/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/devel/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "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": "-l filename --log= filename", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/devel/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/devel/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/devel/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/devel/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/devel/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/devel/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/devel/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/devel/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "label": "20devel", "major": "20", "channel": "devel", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/20/postgresql-20-A4.pdf", "bytes": 16030631, "pages": 3052, "sha256": "bd5d82c0ce38fc18f92a0447818a91a193a261776bca1c37564bf9a683e177d0", "built_at": "2026-09-28"}, "US": {"url": "/files/documentation/pdf/20/postgresql-20-US.pdf", "bytes": 15936613, "pages": 3223, "sha256": "d97d9e0db479a02f4234b175f50fcad70c3661619afc8d6df9b9437882e3c299", "built_at": "2026-09-28"}}, "tree": "0", "index": "index.html", "major": "20", "pages": 1156, "release": "20devel", "source_url": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "svg_assets": 6, "source_mode": "en SGML built with pinned official archive", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41", "source_snapshot_utc": "26-Sep-2026 20:22"}, "revision": "2eba5e0fd4c3bffb2803247b6cd537878e9d6ee5a6dfbe3c50ece8b421b80918", "evidence_kind": "English manual and source declarations", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41"}, "sources": [{"url": "/docs/devel/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "20devel English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "06ed3d8c295297d0ef293c8cbf7723637bfa791b7c1a5e5186687975e1d2da4b"}, {"url": "/docs/devel/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "5532c1ebfb8c6f310301be63a28daf0ae212e2a78025bea61a1bdca99e02c43d"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/devel/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/devel/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/devel/logfile-maintenance.html\" title=\"24.3.\u00a0Log File Maintenance\">Section\u00a024.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/devel/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/devel/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/devel/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"/docs/devel/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "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": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53"}}}, "snapshot": {"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"}], "tables": [{"key": "options", "rows": [{"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-c --core-files"}}, {"summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-D datadir --pgdata= datadir"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-l filename --log= filename"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-m mode --mode= mode"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-o options --options= options"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-o initdb-options --options= initdb-options"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-p path"}}, {"summary": "Print only errors, no informational messages.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-s --silent"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-t seconds --timeout= seconds"}}, {"summary": "Print the pg_ctl version and exit.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-V --version"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-w --wait"}}, {"summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-W --no-wait"}}, {"summary": "Show help about pg_ctl command line arguments, and exit.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-? --help"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-e source"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-N servicename"}}, {"summary": "Password for the user to run the service as.", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-P password"}}, {"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": {"url": "/docs/18/app-pg-ctl.html", "text": "-S start-type"}}, {"summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": {"url": "/docs/18/app-pg-ctl.html", "text": "-U username"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-c", "--core-files"], "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": "-c --core-files", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-D datadir", "--pgdata= datadir"], "summary": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used.", "signature": "-D datadir --pgdata= datadir", "source_url": "/docs/18/app-pg-ctl.html", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "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": "-l filename --log= filename", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-m mode", "--mode= mode"], "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": "-m mode --mode= mode", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-o options", "--options= options"], "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": "-o options --options= options", "source_url": "/docs/18/app-pg-ctl.html", "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 initdb-options", "--options= initdb-options"], "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": "-o initdb-options --options= initdb-options", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-p path"], "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": "-p path", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-s", "--silent"], "summary": "Print only errors, no informational messages.", "signature": "-s --silent", "source_url": "/docs/18/app-pg-ctl.html", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "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": "-t seconds --timeout= seconds", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-V", "--version"], "summary": "Print the pg_ctl version and exit.", "signature": "-V --version", "source_url": "/docs/18/app-pg-ctl.html", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "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": "-w --wait", "source_url": "/docs/18/app-pg-ctl.html", "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", "--no-wait"], "summary": "Do not wait for the operation to complete. This is the opposite of the option -w .", "signature": "-W --no-wait", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-?", "--help"], "summary": "Show help about pg_ctl command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/18/app-pg-ctl.html", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "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": "-e source", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-N servicename"], "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": "-N servicename", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-P password"], "summary": "Password for the user to run the service as.", "signature": "-P password", "source_url": "/docs/18/app-pg-ctl.html", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "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": "-S start-type", "source_url": "/docs/18/app-pg-ctl.html", "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": ["-U username"], "summary": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username .", "signature": "-U username", "source_url": "/docs/18/app-pg-ctl.html", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\username ."}], "related": [], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "/docs/18/app-pg-ctl.html", "file": "app-pg-ctl.html", "label": "18.6 English manual \u00b7 app-pg-ctl.html", "anchor": "", "sha256": "bf10289e73df34e48912e8612d5df29f8a8145a2250627d8c099ed59eae23339"}, {"url": "/docs/18/reference-server.html", "file": "reference-server.html", "label": "Server applications inventory", "anchor": "", "sha256": "e9f8bbcc8e3641fadd1d20991e8aad6b532155b786ba5a1b7b364ec4f1a5bef3"}], "sections": [], "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 ]"], "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 ]", "description": ["pg_ctl \u2014 initialize, start, stop, or control a PostgreSQL server"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PG-CTL\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_ctl</span></span></h2>\n<p>pg_ctl \u2014 initialize, start, stop, or control a <span class=\"productname\">PostgreSQL</span> server</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.1\"><code class=\"command\">pg_ctl</code> <code class=\"option\">init[db]</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>initdb-options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.2\"><code class=\"command\">pg_ctl</code> <code class=\"option\">start</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-l</code> <em class=\"replaceable\"><code>filename</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-p</code> <em class=\"replaceable\"><code>path</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.3\"><code class=\"command\">pg_ctl</code> <code class=\"option\">stop</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.4\"><code class=\"command\">pg_ctl</code> <code class=\"option\">restart</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-m</code> <code class=\"option\">s[mart]</code> | <code class=\"option\">f[ast]</code> | <code class=\"option\">i[mmediate]</code> ] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>] [<code class=\"option\">-c</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.5\"><code class=\"command\">pg_ctl</code> <code class=\"option\">reload</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.6\"><code class=\"command\">pg_ctl</code> <code class=\"option\">status</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.7\"><code class=\"command\">pg_ctl</code> <code class=\"option\">promote</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.8\"><code class=\"command\">pg_ctl</code> <code class=\"option\">logrotate</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-s</code>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.9\"><code class=\"command\">pg_ctl</code> <code class=\"option\">kill</code> <em class=\"replaceable\"><code>signal_name</code></em> <em class=\"replaceable\"><code>process_id</code></em></p>\n</div>\n<p>On Microsoft Windows, also:</p>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.11\"><code class=\"command\">pg_ctl</code> <code class=\"option\">register</code> [<code class=\"option\">-D</code> <em class=\"replaceable\"><code>datadir</code></em>] [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>] [<code class=\"option\">-U</code> <em class=\"replaceable\"><code>username</code></em>] [<code class=\"option\">-P</code> <em class=\"replaceable\"><code>password</code></em>] [<code class=\"option\">-S</code> <code class=\"option\">a[uto]</code> | <code class=\"option\">d[emand]</code> ] [<code class=\"option\">-e</code> <em class=\"replaceable\"><code>source</code></em>] [<code class=\"option\">-W</code>] [<code class=\"option\">-t</code> <em class=\"replaceable\"><code>seconds</code></em>] [<code class=\"option\">-s</code>] [<code class=\"option\">-o</code> <em class=\"replaceable\"><code>options</code></em>]</p>\n</div>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.5.8.4.12\"><code class=\"command\">pg_ctl</code> <code class=\"option\">unregister</code> [<code class=\"option\">-N</code> <em class=\"replaceable\"><code>servicename</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_ctl</span> is a utility for initializing a <span class=\"productname\">PostgreSQL</span> database cluster, starting, stopping, or restarting the <span class=\"productname\">PostgreSQL</span> database server (<a class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>), or displaying the status of a running server. Although the server can be started manually, <span class=\"application\">pg_ctl</span> encapsulates tasks such as redirecting log output and properly detaching from the terminal and process group. It also provides convenient options for controlled shutdown.</p>\n<p>The <code class=\"option\">init</code> or <code class=\"option\">initdb</code> mode creates a new <span class=\"productname\">PostgreSQL</span> database cluster, that is, a collection of databases that will be managed by a single server instance. This mode invokes the <code class=\"command\">initdb</code> command. See <a class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a> for details.</p>\n<p><code class=\"option\">start</code> mode launches a new server. The server is started in the background, and its standard input is attached to <code class=\"filename\">/dev/null</code> (or <code class=\"literal\">nul</code> on Windows). On Unix-like systems, by default, the server's standard output and standard error are sent to <span class=\"application\">pg_ctl</span>'s standard output (not standard error). The standard output of <span class=\"application\">pg_ctl</span> should then be redirected to a file or piped to another process such as a log rotating program like <span class=\"application\">rotatelogs</span>; otherwise <code class=\"command\">postgres</code> 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 <code class=\"option\">-l</code> to append the server's output to a log file. Use of either <code class=\"option\">-l</code> or output redirection is recommended.</p>\n<p><code class=\"option\">stop</code> mode shuts down the server that is running in the specified data directory. Three different shutdown methods can be selected with the <code class=\"option\">-m</code> option. <span class=\"quote\">\u201c<span class=\"quote\">Smart</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Fast</span>\u201d</span> 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. <span class=\"quote\">\u201c<span class=\"quote\">Immediate</span>\u201d</span> 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.</p>\n<p><code class=\"option\">restart</code> mode effectively executes a stop followed by a start. This allows changing the <code class=\"command\">postgres</code> 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, <code class=\"option\">restart</code> might fail unless <span class=\"application\">pg_ctl</span> is executed in the same current directory as it was during server start.</p>\n<p><code class=\"option\">reload</code> mode simply sends the <code class=\"command\">postgres</code> server process a <span class=\"systemitem\">SIGHUP</span> signal, causing it to reread its configuration files (<code class=\"filename\">postgresql.conf</code>, <code class=\"filename\">pg_hba.conf</code>, etc.). This allows changing configuration-file options that do not require a full server restart to take effect.</p>\n<p><code class=\"option\">status</code> 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, <span class=\"application\">pg_ctl</span> returns an exit status of 3. If an accessible data directory is not specified, <span class=\"application\">pg_ctl</span> returns an exit status of 4.</p>\n<p><code class=\"option\">promote</code> mode commands the standby server that is running in the specified data directory to end standby mode and begin read-write operations.</p>\n<p><code class=\"option\">logrotate</code> mode rotates the server log file. For details on how to use this mode with external log rotation tools, see <a class=\"xref\" href=\"/docs/18/logfile-maintenance.html\" title=\"24.3.\u00a0Log File Maintenance\">Section\u00a024.3</a>.</p>\n<p><code class=\"option\">kill</code> mode sends a signal to a specified process. This is primarily valuable on <span class=\"productname\">Microsoft Windows</span> which does not have a built-in <span class=\"application\">kill</span> command. Use <code class=\"literal\">--help</code> to see a list of supported signal names.</p>\n<p><code class=\"option\">register</code> mode registers the <span class=\"productname\">PostgreSQL</span> server as a system service on <span class=\"productname\">Microsoft Windows</span>. The <code class=\"option\">-S</code> option allows selection of service start type, either <span class=\"quote\">\u201c<span class=\"quote\">auto</span>\u201d</span> (start service automatically on system startup) or <span class=\"quote\">\u201c<span class=\"quote\">demand</span>\u201d</span> (start service on demand).</p>\n<p><code class=\"option\">unregister</code> mode unregisters a system service on <span class=\"productname\">Microsoft Windows</span>. This undoes the effects of the <code class=\"option\">register</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PG-CTL-OPTIONS\">\n<h2>Options</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--core-files</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-D <em class=\"replaceable\"><code>datadir</code></em></code><br></span><span class=\"term\"><code class=\"option\">--pgdata=<em class=\"replaceable\"><code>datadir</code></em></code></span></dt>\n<dd>\n<p>Specifies the file system location of the database configuration files. If this option is omitted, the environment variable <code class=\"envar\">PGDATA</code> is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-l <em class=\"replaceable\"><code>filename</code></em></code><br></span><span class=\"term\"><code class=\"option\">--log=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Append the server log output to <em class=\"replaceable\"><code>filename</code></em>. 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-m <em class=\"replaceable\"><code>mode</code></em></code><br></span><span class=\"term\"><code class=\"option\">--mode=<em class=\"replaceable\"><code>mode</code></em></code></span></dt>\n<dd>\n<p>Specifies the shutdown mode. <em class=\"replaceable\"><code>mode</code></em> can be <code class=\"literal\">smart</code>, <code class=\"literal\">fast</code>, or <code class=\"literal\">immediate</code>, or the first letter of one of these three. If this option is omitted, <code class=\"literal\">fast</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">postgres</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o <em class=\"replaceable\"><code>initdb-options</code></em></code><br></span><span class=\"term\"><code class=\"option\">--options=<em class=\"replaceable\"><code>initdb-options</code></em></code></span></dt>\n<dd>\n<p>Specifies options to be passed directly to the <code class=\"command\">initdb</code> command. <code class=\"option\">-o</code> can be specified multiple times, with all the given options being passed through.</p>\n<p>The <em class=\"replaceable\"><code>initdb-options</code></em> should usually be surrounded by single or double quotes to ensure that they are passed through as a group.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>path</code></em></code></span></dt>\n<dd>\n<p>Specifies the location of the <code class=\"filename\">postgres</code> executable. By default the <code class=\"filename\">postgres</code> executable is taken from the same directory as <code class=\"command\">pg_ctl</code>, 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 <code class=\"filename\">postgres</code> executable was not found.</p>\n<p>In <code class=\"literal\">init</code> mode, this option analogously specifies the location of the <code class=\"filename\">initdb</code> executable.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--silent</code></span></dt>\n<dd>\n<p>Print only errors, no informational messages.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>seconds</code></em></code><br></span><span class=\"term\"><code class=\"option\">--timeout=<em class=\"replaceable\"><code>seconds</code></em></code></span></dt>\n<dd>\n<p>Specifies the maximum number of seconds to wait when waiting for an operation to complete (see option <code class=\"option\">-w</code>). Defaults to the value of the <code class=\"envar\">PGCTLTIMEOUT</code> environment variable or, if not set, to 60 seconds.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_ctl</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--wait</code></span></dt>\n<dd>\n<p>Wait for the operation to complete. This is supported for the modes <code class=\"literal\">start</code>, <code class=\"literal\">stop</code>, <code class=\"literal\">restart</code>, <code class=\"literal\">promote</code>, and <code class=\"literal\">register</code>, and is the default for those modes.</p>\n<p>When waiting, <code class=\"command\">pg_ctl</code> 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. <code class=\"command\">pg_ctl</code> returns an exit code based on the success of the startup or shutdown.</p>\n<p>If the operation does not complete within the timeout (see option <code class=\"option\">-t</code>), then <code class=\"command\">pg_ctl</code> exits with a nonzero exit status. But note that the operation might continue in the background and eventually succeed.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--no-wait</code></span></dt>\n<dd>\n<p>Do not wait for the operation to complete. This is the opposite of the option <code class=\"option\">-w</code>.</p>\n<p>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.</p>\n<p>In prior releases of PostgreSQL, this was the default except for the <code class=\"literal\">stop</code> mode.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_ctl</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>If an option is specified that is valid, but not relevant to the selected operating mode, <span class=\"application\">pg_ctl</span> ignores it.</p>\n<div class=\"refsect2\" id=\"APP-PG-CTL-WINDOWS-OPTIONS\">\n<h3>Options for Windows</h3>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>source</code></em></code></span></dt>\n<dd>\n<p>Name of the event source for <span class=\"application\">pg_ctl</span> to use for logging to the event log when running as a Windows service. The default is <code class=\"literal\">PostgreSQL</code>. Note that this only controls messages sent from <span class=\"application\">pg_ctl</span> itself; once started, the server will use the event source specified by its <a class=\"xref\" href=\"/docs/18/runtime-config-logging.html#GUC-EVENT-SOURCE\">event_source</a> 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 <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>servicename</code></em></code></span></dt>\n<dd>\n<p>Name of the system service to register. This name will be used as both the service name and the display name. The default is <code class=\"literal\">PostgreSQL</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-P <em class=\"replaceable\"><code>password</code></em></code></span></dt>\n<dd>\n<p>Password for the user to run the service as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>start-type</code></em></code></span></dt>\n<dd>\n<p>Start type of the system service. <em class=\"replaceable\"><code>start-type</code></em> can be <code class=\"literal\">auto</code>, or <code class=\"literal\">demand</code>, or the first letter of one of these two. If this option is omitted, <code class=\"literal\">auto</code> is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name for the user to run the service as. For domain users, use the format <code class=\"literal\">DOMAIN\\username</code>.</p>\n</dd>\n</dl>\n</div>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGCTLTIMEOUT</code></span></dt>\n<dd>\n<p>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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PGDATA</code></span></dt>\n<dd>\n<p>Default data directory location.</p>\n</dd>\n</dl>\n</div>\n<p>Most <code class=\"command\">pg_ctl</code> modes require knowing the data directory location; therefore, the <code class=\"option\">-D</code> option is required unless <code class=\"envar\">PGDATA</code> is set.</p>\n<p>For additional variables that affect the server, see <a class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a>.</p>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.8\">\n<h2>Files</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"filename\">postmaster.pid</code></span></dt>\n<dd>\n<p><span class=\"application\">pg_ctl</span> examines this file in the data directory to determine whether the server is currently running.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"filename\">postmaster.opts</code></span></dt>\n<dd>\n<p>If this file exists in the data directory, <span class=\"application\">pg_ctl</span> (in <code class=\"option\">restart</code> mode) will pass the contents of the file as options to <span class=\"application\">postgres</span>, unless overridden by the <code class=\"option\">-o</code> option. The contents of this file are also displayed in <code class=\"option\">status</code> mode.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"R1-APP-PGCTL-2\">\n<h2>Examples</h2>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-3\">\n<h3>Starting the Server</h3>\n<p>To start the server, waiting until the server is accepting connections:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl start</code></strong>\n</pre>\n<p>To start the server using port 5433, and running without <code class=\"function\">fsync</code>, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" start</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-4\">\n<h3>Stopping the Server</h3>\n<p>To stop the server, use:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop</code></strong>\n</pre>\n<p>The <code class=\"option\">-m</code> option allows control over <span class=\"emphasis\"><em>how</em></span> the server shuts down:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl stop -m smart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-5\">\n<h3>Restarting the Server</h3>\n<p>Restarting the server is almost equivalent to stopping the server and starting it again, except that by default, <code class=\"command\">pg_ctl</code> 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:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl restart</code></strong>\n</pre>\n<p>But if <code class=\"option\">-o</code> is specified, that replaces any previous options. To restart using port 5433, disabling <code class=\"function\">fsync</code> upon restart:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl -o \"-F -p 5433\" restart</code></strong>\n</pre>\n</div>\n<div class=\"refsect2\" id=\"R2-APP-PGCTL-6\">\n<h3>Showing the Server Status</h3>\n<p>Here is sample status output from <span class=\"application\">pg_ctl</span>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_ctl status</code></strong>\n<code class=\"computeroutput\">\npg_ctl: server is running (PID: 13718)\n/usr/local/pgsql/bin/postgres \"-D\" \"/usr/local/pgsql/data\" \"-p\" \"5433\" \"-B\" \"128\"\n</code>\n</pre>\n<p>The second line is the command that would be invoked in restart mode.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.5.8.10\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/18/app-initdb.html\" title=\"initdb\"><span class=\"refentrytitle\"><span class=\"application\">initdb</span></span></a>, <a class=\"xref\" href=\"/docs/18/app-postgres.html\" title=\"postgres\"><span class=\"refentrytitle\"><span class=\"application\">postgres</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pg-ctl.html", "comparison_data": {"options": [{"names": ["-c", "--core-files"], "signature": "-c --core-files", "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": ["-D datadir", "--pgdata= datadir"], "signature": "-D datadir --pgdata= datadir", "description": "Specifies the file system location of the database configuration files. If this option is omitted, the environment variable PGDATA is used."}, {"names": ["-l filename", "--log= filename"], "signature": "-l filename --log= filename", "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": ["-m mode", "--mode= mode"], "signature": "-m mode --mode= mode", "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": ["-o options", "--options= options"], "signature": "-o options --options= options", "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 initdb-options", "--options= initdb-options"], "signature": "-o initdb-options --options= initdb-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": ["-p path"], "signature": "-p path", "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": ["-s", "--silent"], "signature": "-s --silent", "description": "Print only errors, no informational messages."}, {"names": ["-t seconds", "--timeout= seconds"], "signature": "-t seconds --timeout= seconds", "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": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_ctl version and exit."}, {"names": ["-w", "--wait"], "signature": "-w --wait", "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", "--no-wait"], "signature": "-W --no-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": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_ctl command line arguments, and exit."}, {"names": ["-e source"], "signature": "-e source", "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": ["-N servicename"], "signature": "-N servicename", "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": ["-P password"], "signature": "-P password", "description": "Password for the user to run the service as."}, {"names": ["-S start-type"], "signature": "-S start-type", "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": ["-U username"], "signature": "-U username", "description": "User name for the user to run the service as. For domain users, use the format DOMAIN\\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 ]"], "environment": [{"name": "PGCTLTIMEOUT", "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": "PGDATA", "description": "Default data directory location."}]}, "comparison_hash": "4f93544f233f78079879f3558fb85c50105c0a56ac14b06e075ce6a0b934ea53"}, "comparison": {"left": "13", "right": "14", "status": "changed", "diff": "--- PostgreSQL 13\n+++ PostgreSQL 14\n@@ -27,7 +27,7 @@\n       \"signature\": \"-D datadir --pgdata= datadir\"\n     },\n     {\n-      \"description\": \"Append the server log output to filename . If the file does not exist, it is created. The umask is set to 077, so access to the log file is disallowed to other users by default.\",\n+      \"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.\",\n       \"names\": [\n         \"-l filename\",\n         \"--log= filename\""}}