Re: Checking that Pg is running from a shell script

From: Thomas Beutin <tyrone(at)laokoon(dot)IN-Berlin(dot)DE>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Checking that Pg is running from a shell script
Date: 2002-06-10 17:16:29
Message-ID: 20020610191629.B12071@laokoon.bug.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

if You have fuser on Your system You can check the process
listening on the postgres port 5432:
fuser -n tcp 5432 | wc -l
returns 1 (a line containing only "1" and whitespace) if there
is a process listening on this port and 0 if is not.
Another choice is to look for a process with the pid from
../data/postmaster.pid (probably the better choice).

-tb

On Mon, Jun 10, 2002 at 10:29:06AM -0400, 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.
>
> Thanks,
> Fran
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Thomas Beutin tb(at)laokoon(dot)IN-Berlin(dot)DE
Beam me up, Scotty. There is no intelligent live down in Redmond.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2002-06-10 17:20:10 Re: [SQL] VIEWs and FOREIGN keys
Previous Message Bruce Momjian 2002-06-10 17:11:48 Re: Checking that Pg is running from a shell script