Sunday, 1 November 2020

Find Uptime in PostgreSQL

 There are various ways to know since how long PostgreSQL is running. 

Below will cover 3 ways to find this.


  Using OS-level command

# service postgresql status



  Using SQL query

SELECT   CURRENT_DATE - (pg_postmaster_start_time())::DATE AS up_day,
CURRENT_TIMESTAMP -pg_postmaster_start_time() AS up_time,
pg_postmaster_start_time() AS start_time;

       



        Using PID

pg_ctl -D /var/lib/pgsql/pg10/data -l logfile status
pg_ctl: server is running (PID: 23293)

bash-4.1$ ls -ld /proc/23293
dr-xr-xr-x 8 postgres postgres 0 Sep 14 20:28 /proc/23293










Found this post interesting? Subscribe us  :)😊😉


Read more 

Configure Streaming Replication in PostgreSQL

All about Physical Replication and Log shipping in Postgres 

Streaming-Replication Sync and Async, benefits of streaming replication over Log-shipping





No comments:

Post a Comment