From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Travis Hume <travis(dot)hume(at)tenzing(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org, Breck Thomas <Breck(dot)Thomas(at)tenzing(dot)com> |
Subject: | Re: need a method to ping a running database |
Date: | 2003-06-12 04:32:48 |
Message-ID: | 26498.1055392368@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Travis Hume <travis(dot)hume(at)tenzing(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2003-06-12 04:34:52 | Re: LC_COLLATE=es_MX in PgSQL 7.3.2 |
Previous Message | Tom Lane | 2003-06-12 04:19:47 | Re: LC_COLLATE=es_MX in PgSQL 7.3.2 |