Re: need a method to ping a running database
| От | Tom Lane |
|---|---|
| Тема | Re: need a method to ping a running database |
| Дата | |
| Msg-id | 26498.1055392368@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | need a method to ping a running database (Travis Hume <travis.hume@tenzing.com>) |
| Список | pgsql-general |
Travis Hume <travis.hume@tenzing.com> writes:
> I need a shell scriptable method to determine if a postgresql database
> is running and accepting connections.
Right now I think the best you can do is see if a command actually
succeeds, eg try
psql -c "select 1"
and see if it complains.
There are some speculations in the archives about writing a pg_ping
utility that would check to see if the postmaster is alive without
expending the overhead of really executing a SQL command --- but no
one's got round to writing any code for it, AFAIK. In any case, psql -c
is a bit more thorough of a test, since it not only checks whether the
database is alive but whether it is willing to accept commands from
*you*. I can think of scenarios where each kind of test would be more
appropriate, so it's something you have to make up your own mind about.
regards, tom lane
В списке pgsql-general по дате отправления: