postmaster.pid

The pidfile written by the postmaster process

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.

Usage

postmaster.pid is automatically written by the postmaster process at startup to the data directory, and is removed after a normal shutdown.

If 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.

Contents

Item Example From Notes
PID 17454 PostgreSQL 7.0  
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 starting, stopping, ready, standby

Note that the number of rows and their order may change between PostgreSQL versions.

Source code

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:

Change history

Examples

$ cat /var/lib/pgsql/data/postmaster.pid
17454
/var/lib/pgsql/data
1603954420
5432
/tmp
127.0.0.1
  5432001   9437184
ready  

Categories

Data directory, PostgreSQL internals

See also

external_pid_file, postmaster