There are countless ways of understanding how long PostgreSQL has been turned on.
In this article we will talk about 3 methods.
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;
2)From Service Definitions:
Firstly, we look at the status of the service with the following query.
systemctl status postgresql
3) Using PID:
First we take the PID of the PostgreSQL master process.
ps hf -C postgres
That’s 485. Then we look at when the process begins. There are various ways of doing this. One of these;
ls -ld /proc/You must write PID here.