There are countless ways of understanding how long PostgreSQL has been turned on.
In this article we will talk about 3 methods.
1)Using SQL:
1 2 3 4 |
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; |
2)From Service Definitions:
Firstly, we look at the status of the service with the following query.
1 |
systemctl status postgresql |
3) Using PID:
First we take the PID of the PostgreSQL master process.
1 |
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;
1 |
ls -ld /proc/You must write PID here. |