Wednesday, April 7, 2021

Using pg_ctl command Start and Stop Postgres database in Linux






[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$ pg_ctl -D /pgdatabase/data/ -l /pglog/db_logs/start.log status

pg_ctl: no server running

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$ pg_ctl -D /pgdatabase/data/ -l /pglog/db_logs/start.log start

pg_ctl: another server might be running; trying to start server anyway

waiting for server to start.... done

server started

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$


[postgres@pgsql ~]$

[postgres@pgsql ~]$ pg_ctl -D /pgdatabase/data/ -l /pglog/db_logs/start.log status

pg_ctl: server is running (PID: 4119)

/opt/PostgreSQL_10/bin/postgres "-D" "/pgdatabase/data"

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$ ps -ef | grep -i pg

avahi      770     1  0 15:28 ?        00:00:00 avahi-daemon: running [pgsql.local]

postgres  4119     1  0 16:45 ?        00:00:00 /opt/PostgreSQL_10/bin/postgres -D /pgdatabase/data

postgres  4129  3900  0 16:46 pts/1    00:00:00 grep --color=auto -i pg

[postgres@pgsql ~]$ ps -ef | grep -i pgsql

avahi      770     1  0 15:28 ?        00:00:00 avahi-daemon: running [pgsql.local]

postgres  4139  3900  0 16:46 pts/1    00:00:00 grep --color=auto -i pgsql

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$ psql

psql (12.6)

Type "help" for help.


postgres=# 

postgres'#

postgres'#

postgres'#




[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$ pg_ctl -D /pgdatabase/data/ -l /pglog/db_logs/start.log stop

waiting for server to shut down.... done

server stopped

[postgres@pgsql ~]$

[postgres@pgsql ~]$


[postgres@pgsql ~]$

[postgres@pgsql ~]$ pg_ctl -D /pgdatabase/data/ -l /pglog/db_logs/start.log stop -m fast

waiting for server to shut down.... done

server stopped

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$

[postgres@pgsql ~]$ pg_ctl -D /pgdatabase/data/ -l /pglog/db_logs/start.log status

pg_ctl: no server running

[postgres@pgsql ~]$

[postgres@pgsql ~]$



No comments:

Post a Comment

About the Author : Anurag Pandey | Database cloud Architect | Oracle | SQL Server | PostgreSQL | AI and Data Platform Enthusiast

Anurag Pandey is a Database Architect with expertise in Oracle, PostgreSQL, SQL Server, Linux, and enterprise database platforms and specializes in database architecture, performance tuning, high availability, disaster recovery, cloud modernization, and operational excellence. With extensive experience in enterprise-scale environments, Anurag is passionate about leveraging AI, automation, and modern data platforms to improve reliability, scalability, and business outcomes. He actively contributes to technical communities through knowledge sharing, architecture guidance, and thought leadership in database and data engineering domains.

Follow more articles at

Visit Blog

Wish you happy diwali 2026