Re: Checking that Pg is running from a shell script

From: Ericson Smith <eric(at)did-it(dot)com>
To: Vincent Stoessel <vincent(at)xaymaca(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Checking that Pg is running from a shell script
Date: 2002-06-10 21:01:52
Message-ID: 1023742913.28477.8.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

We use this small attached perl script to directly check the port on 2
running DB servers and write the status to a file. Our webserver farm
then checks this file every time we need to use the DB.

In our case, we just serve up static content if there is no database,
otherwise we continue our work.

This script will also timeout after 10 seconds, so it wont wait forever
checking a dead PG port.

- Ericson Smith
info(at)w3matter(dot)com
http://www.swapyourcrap.com

On Mon, 2002-06-10 at 15:33, Vincent Stoessel wrote:
> Can pg_ctl across the network? I'd like my middleware server to know
> if my postgres db is up and running OK. I guess I could just make a
> db connection but I was hoping for a more elegant solution.
> Thanks.
>
> Fran Fabrizio wrote:
> > Lamar Owen wrote:
> >
> >> On Monday 10 June 2002 10:29 am, Fran Fabrizio wrote:
> >>
> >>
> >>> What's the best way to ensure that Pg is running from a shell script?
> >>> I'm crafting a few RPMs for my projects, one of which will attempt to
> >>> load data into a database, but I want to check that it's running first
> >>> before I try this
> >>>
> >> See the man page for pg_ctl. There is, IIRC, a status option, but you
> >> have to know the location of PGDATA (which, in a vanilla RPM install
> >> is /var/lib/pgsql/data).
> >>
> >>
> >
> > Thanks all, the pg_ctl -D /var/lib/pgsql/data status should be
> > sufficient for my needs.
> >
> > -Fran
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
>
>
>
> --
> Vincent Stoessel
> Linux Systems Developer
> vincent xaymaca.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

Attachment Content-Type Size
dbcheck.pl text/x-perl 903 bytes

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message McCaffity, Ray (Contractor) 2002-06-10 22:15:38 Re: Checking that Pg is running from a shell script
Previous Message Tom Lane 2002-06-10 20:51:09 Re: Checking that Pg is running from a shell script