Re: Checking that Pg is running from a shell script

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Fran Fabrizio <ffabrizio(at)mmrd(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Checking that Pg is running from a shell script
Date: 2002-06-10 17:11:48
Message-ID: 200206101711.g5AHBma22669@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.
>
> I'm a shell scripting newbie so apologies if the answer is really
> straightforward. I don't know if UNIX processes leave a standard trail
> so that I could just look up if something is listening on 5432, for
> example.

Sure, pg_ctl status:

$ pg_ctl status
pg_ctl: postmaster is running (pid: 7340)
Command line was:
/usr/var/local/postgres/./bin/postmaster '-o' ''

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Beutin 2002-06-10 17:16:29 Re: Checking that Pg is running from a shell script
Previous Message Vincent Stoessel 2002-06-10 17:01:36 Re: size of units in postgresql.conf