postmaster.pid is the pidfile written by the postmaster process. As well the postmaster's PID, it contains additional information about the running instance.
postmaster.pid was added in PostgreSQL 7.0.
postmaster.pid is automatically written by the postmaster process at startup to the data directory, and is removed after a normal shutdown.
external_pid_file is set, an additional copy of the file is written at the specified location for use by the operating system (e.g. systemd), containing just the PID.
|Data directory||/var/lib/pgsql/data||PostgreSQL 7.1|
|postmaster start timestamp||1603954420||PostgreSQL 9.1||Unix epoch|
|Port number||5432||PostgreSQL 9.1|
|First Unix socket directory path||/tmp||PostgreSQL 9.1||empty if none|
|First listen_address||127.0.0.1||PostgreSQL 9.1||IP address or "*"; empty if no TCP port|
|shared memory key||5432001 9437184||PostgreSQL 7.1||empty on Windows|
|postmaster status||ready||PostgreSQL 10||one of
Note that the number of rows and their order may change between PostgreSQL versions.
The filename is defined in src/backend/utils/init/miscinit.c:
#define DIRECTORY_LOCK_FILE "postmaster.pid"
The file itself is created by function
CreateLockFile(), invoked by
CreateDataDirLockFile(), also in src/backend/utils/init/miscinit.c.
Relevant declarations are contained in the following file:
- src/include/utils/pidfile.h (PostgreSQL 10 and later)
- src/include/miscadmin.h (PostgreSQL 9.6 and earlier)
- PostgreSQL 10
- additional line with postmaster status added (commit f13ea95f)
- PostgreSQL 9.1
- PostgreSQL 7.1
- PostgreSQL 7.0
- added (commit dde36bfb)
$ cat /var/lib/pgsql/data/postmaster.pid 17454 /var/lib/pgsql/data 1603954420 5432 /tmp 127.0.0.1 5432001 9437184 ready