Skip site navigation (1) Skip section navigation (2)

Re: How to check postgres running or not ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Geoffrey <esoteric(at)3times25(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to check postgres running or not ?
Date: 2004-09-19 16:25:00
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Geoffrey <esoteric(at)3times25(dot)net> writes:
> Worik wrote:
>> Assuming it is unix....  The command
>> ps xau|grep post

> You might want to change that to:
> ps aux|grep postgres
> As your suggestion will pick up extraneous data if one is running 
> postfix on the same box.

Actually I'd recommend grepping for "postmaster".  If your PG user is
named "postgres" then the above command will find any program the PG
user is running --- which might only be a shell, for instance.  If your
PG user is not named "postgres" then the above might find nothing at
all, even though the postmaster is alive (since depending on the details
of your local ps command, it might report all the server processes as

There is even another gotcha, which is that the "grep postmaster"
command could easily find itself in the ps output.  So what really
works is
	ps aux | grep postmaster | grep -v grep
(or use "ps -ef" if using a SysV-ish ps).

Obviously none of this matters if you are just going to eyeball the
output, but if you want something suitable for a test in a script,
you'd better use something like the last one.

			regards, tom lane

In response to


pgsql-sql by date

Next:From: T E SchmitzDate: 2004-09-19 16:36:36
Subject: Re: ORDER BY and NULLs
Previous:From: Jean-Luc LachanceDate: 2004-09-19 16:19:55
Subject: Re: ORDER BY and NULLs

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group