LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

pg_ctl

utility for initializing, starting, stopping, and controlling a PostgreSQL

TLDR

Start PostgreSQL
$ pg_ctl start -D [/var/lib/postgresql/data]
copy
Stop PostgreSQL
$ pg_ctl stop -D [/var/lib/postgresql/data]
copy
Restart PostgreSQL
$ pg_ctl restart -D [/var/lib/postgresql/data]
copy
Reload configuration
$ pg_ctl reload -D [/var/lib/postgresql/data]
copy
Check status
$ pg_ctl status -D [/var/lib/postgresql/data]
copy

SYNOPSIS

pg_ctl action [-D datadir] [options]

DESCRIPTION

pg_ctl is a utility for initializing, starting, stopping, and controlling a PostgreSQL database server. It's the preferred method for managing PostgreSQL services.

PARAMETERS

start

Start the server.
stop
Stop the server.
restart
Stop then start.
reload
Reload configuration.
status
Check server status.
-D directory
Data directory.
-m mode
Shutdown mode (smart, fast, immediate).
-l file
Log file.
-w
Wait for completion.

Start with logging

pg_ctl start -D /data -l /var/log/postgresql.log

Fast shutdown

pg_ctl stop -D /data -m fast

Initialize new cluster

pg_ctl initdb -D /data

Promote standby

pg_ctl promote -D /data

$
# SHUTDOWN MODES
copy
smart - Wait for clients to disconnectfast - Rollback active transactions (default)immediate - Abort immediately (may corrupt)
$
# CAVEATS

Must run as PostgreSQL user. Data directory required. Use systemctl on systemd systems.

# HISTORY

pg_ctl is part of **PostgreSQL**, the open source database originally from UC Berkeley's POSTGRES project.

# SEE ALSO

postgres(1), pg_dump(1), pg_restore(1), initdb(1)

# INSTALL
copy
$ apk: sudo apk add postgresql17
copy
$ zypper: sudo zypper install postgresql17
copy

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid