X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B2770329E70 for ; Sun, 19 Sep 2004 18:12:13 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58222-07 for ; Sun, 19 Sep 2004 17:12:10 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7B025329CAE for ; Sun, 19 Sep 2004 18:12:09 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i8JHC8kq019877; Sun, 19 Sep 2004 13:12:08 -0400 (EDT) To: Andrew Sullivan Cc: pgsql-sql@postgresql.org Subject: Re: How to check postgres running or not ? In-reply-to: <20040919165748.GB15746@phlogiston.dyndns.org> References: <414A7395.8070503@vertex.co.in> <414CE76E.2050405@noggon.com> <414D7533.10708@3times25.net> <19430.1095611100@sss.pgh.pa.us> <20040919165748.GB15746@phlogiston.dyndns.org> Comments: In-reply-to Andrew Sullivan message dated "Sun, 19 Sep 2004 12:57:48 -0400" Date: Sun, 19 Sep 2004 13:12:07 -0400 Message-ID: <19876.1095613927@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/135 X-Sequence-Number: 18981 Andrew Sullivan writes: > On Sun, Sep 19, 2004 at 12:25:00PM -0400, Tom Lane wrote: >> ps aux | grep postmaster | grep -v grep >> (or use "ps -ef" if using a SysV-ish ps). > Except that on Solaris, ps -ef _always_ shows "postmaster", even for > the individual back ends. Right, but if you see a backend then you can figure the system is up. If you are concerned about the case where the postmaster has crashed and yet there are still backends laying about, then the whole "ps" approach is probably wrong anyway. It would make more sense to check whether the postmaster is answering the doorbell --- ie, send a connection request and see what happens. At one time there was discussion of writing a "pg_ping" utility program to do exactly this, but it still hasn't got done. You can fake it to some extent by just running "psql -l >/dev/null" and checking the exit code, but this does require supplying a valid username and possibly a password (because psql's exit code doesn't distinguish "could not connect" from authentication errors). BTW, "pg_ctl status" doesn't answer this need because it only looks for a postmaster.pid file, it doesn't attempt to verify that the postmaster is really alive. regards, tom lane