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 639F7329E70 for ; Sun, 19 Sep 2004 17:25:08 +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 50089-02 for ; Sun, 19 Sep 2004 16:25:05 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2DB28329D9F for ; Sun, 19 Sep 2004 17:25:02 +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 i8JGP0vs019431; Sun, 19 Sep 2004 12:25:00 -0400 (EDT) To: Geoffrey Cc: pgsql-sql@postgresql.org Subject: Re: How to check postgres running or not ? In-reply-to: <414D7533.10708@3times25.net> References: <414A7395.8070503@vertex.co.in> <414CE76E.2050405@noggon.com> <414D7533.10708@3times25.net> Comments: In-reply-to Geoffrey message dated "Sun, 19 Sep 2004 08:01:55 -0400" Date: Sun, 19 Sep 2004 12:25:00 -0400 Message-ID: <19430.1095611100@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/131 X-Sequence-Number: 18977 Geoffrey 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 "postmaster"). 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