snippetsqlModerate
How can I get my server's uptime?
Viewed 0 times
cangethowserveruptime
Problem
I am working with postgresql-9.4 and for support and monitoring tasks I need to know how long my server has been up for? Is there any function or way to know this? Is there an sql way to know when my server started?
I really need to know the elapsed time since it started?
I really need to know the elapsed time since it started?
Solution
Use the built-in function
More details in the manual: http://www.postgresql.org/docs/current/static/functions-info.html
If you want seconds, use
pg_postmaster_start_timeselect current_timestamp - pg_postmaster_start_time() as uptimeMore details in the manual: http://www.postgresql.org/docs/current/static/functions-info.html
If you want seconds, use
extract:select extract(epoch from current_timestamp - pg_postmaster_start_time()) as uptimeCode Snippets
select current_timestamp - pg_postmaster_start_time() as uptimeselect extract(epoch from current_timestamp - pg_postmaster_start_time()) as uptimeContext
StackExchange Database Administrators Q#99428, answer score: 16
Revisions (0)
No revisions yet.