↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / 命令行工具

pg_isready

pg_isready — check the connection status of a PostgreSQL server

当前阅读 PG 18·选择有来源记录的版本

此版本暂无所选语言的定义,以下显示原始英文内容。

Documented executable
pg_isready
Executable version
18.6
Reference inventory
Client applications
Option definition groups
8
environment
未知
manual path
app-pg-isready.html
signature
pg_isready [ connection-option ...] [ option ...]
synopsis
pg_isready [ connection-option ...] [ option ...]

版本定义 PG 18

pg_isready

pg_isready — check the connection status of a PostgreSQL server

Synopsis

pg_isready [connection-option...] [option...]

Description

pg_isready is a utility for checking the connection status of a PostgreSQL database server. The exit status specifies the result of the connection check.

Options

-d dbname
--dbname=dbname

Specifies the name of the database to connect to. The dbname can be a connection string. If so, connection string parameters will override any conflicting command line options.

-h hostname
--host=hostname

Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.

-p port
--port=port

Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432.

-q
--quiet

Do not display status message. This is useful when scripting.

-t seconds
--timeout=seconds

The maximum number of seconds to wait when attempting connection before returning that the server is not responding. Setting to 0 disables. The default is 3 seconds.

-U username
--username=username

Connect to the database as the user username instead of the default.

-V
--version

Print the pg_isready version and exit.

-?
--help

Show help about pg_isready command line arguments, and exit.

Exit Status

pg_isready returns 0 to the shell if the server is accepting connections normally, 1 if the server is rejecting connections (for example during startup), 2 if there was no response to the connection attempt, and 3 if no attempt was made (for example due to invalid parameters).

Environment

pg_isready, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 32.15).

The environment variable PG_COLOR specifies whether to use color in diagnostic messages. Possible values are always, auto and never.

Notes

It is not necessary to supply correct user name, password, or database name values to obtain the server status; however, if incorrect values are provided, the server will log a failed connection attempt.

Examples

Standard Usage:

$ pg_isready
/tmp:5432 - accepting connections
$ echo $?
0

Running with connection parameters to a PostgreSQL cluster in startup:

$ pg_isready -h localhost -p 5433
localhost:5433 - rejecting connections
$ echo $?
1

Running with connection parameters to a non-responsive PostgreSQL cluster:

$ pg_isready -h someremotehost
someremotehost:5432 - no response
$ echo $?
2

Documented options

Option and argumentsDescription
-d dbname --dbname= dbnameSpecifies the name of the database to connect to. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.
-h hostname --host= hostnameSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.
-p port --port= portSpecifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432.
-q --quietDo not display status message. This is useful when scripting.
-t seconds --timeout= secondsThe maximum number of seconds to wait when attempting connection before returning that the server is not responding. Setting to 0 disables. The default is 3 seconds.
-U username --username= usernameConnect to the database as the user username instead of the default.
-V --versionPrint the pg_isready version and exit.
-? --helpShow help about pg_isready command line arguments, and exit.

比较版本

完整来源事实

options

map[description:Specifies the name of the database to connect to. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options. names:[-d dbname --dbname= dbname] signature:-d dbname --dbname= dbname source_url:/docs/18/app-pg-isready.html summary:Specifies the name of the database to connect to. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.], map[description:Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket. names:[-h hostname --host= hostname] signature:-h hostname --host= hostname source_url:/docs/18/app-pg-isready.html summary:Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix-domain socket.], map[description:Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432. names:[-p port --port= port] signature:-p port --port= port source_url:/docs/18/app-pg-isready.html summary:Specifies the TCP port or the local Unix-domain socket file extension on which the server is listening for connections. Defaults to the value of the PGPORT environment variable or, if not set, to the port specified at compile time, usually 5432.], map[description:Do not display status message. This is useful when scripting. names:[-q --quiet] signature:-q --quiet source_url:/docs/18/app-pg-isready.html summary:Do not display status message. This is useful when scripting.], map[description:The maximum number of seconds to wait when attempting connection before returning that the server is not responding. Setting to 0 disables. The default is 3 seconds. names:[-t seconds --timeout= seconds] signature:-t seconds --timeout= seconds source_url:/docs/18/app-pg-isready.html summary:The maximum number of seconds to wait when attempting connection before returning that the server is not responding. Setting to 0 disables. The default is 3 seconds.], map[description:Connect to the database as the user username instead of the default. names:[-U username --username= username] signature:-U username --username= username source_url:/docs/18/app-pg-isready.html summary:Connect to the database as the user username instead of the default.], map[description:Print the pg_isready version and exit. names:[-V --version] signature:-V --version source_url:/docs/18/app-pg-isready.html summary:Print the pg_isready version and exit.], map[description:Show help about pg_isready command line arguments, and exit. names:[-? --help] signature:-? --help source_url:/docs/18/app-pg-isready.html summary:Show help about pg_isready command line arguments, and exit.]

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8

正文语言: en · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8