pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to check postgres running or not ?
22+ messages / 13 participants
[nested] [flat]
* How to check postgres running or not ?
@ 2004-09-17 05:18 Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-18 17:20 ` Re: How to check postgres running or not ? Christopher Browne <cbbrowne@acm.org>
2004-09-18 18:36 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-20 02:33 ` Re: How to check postgres running or not ? Arne Stoelck <stolck@web.de>
2004-09-20 07:20 ` Re: How to check postgres running or not ? Reiner Dassing <dassing@wettzell.ifag.de>
0 siblings, 5 replies; 22+ messages in thread
From: Sandeep Gaikwad @ 2004-09-17 05:18 UTC (permalink / raw)
To: pgsql-sql
Hello Sir,
I want to know how to check whether postgres database is
running or not ? when I give command like ./postmaster -i &, whether
all databases in that postgres will run or any one [default] ? If any
one, then how to detect that database ?
Thanks and regards,
Sandeep.
---------------------------------------------------------
Disclaimer:
The contents of this message are confidential and intended to the addressee at the specified e-mail address only. Its contents may not be copied or disclosed to anyone other than the intended recipient. If this e-mail is received in error, please contact Vertex Software Pvt. Ltd immediately on +91 20 4041500 with details of the sender and addressee and delete the e-mail. Vertex Software Pvt. Ltd accepts no responsibility in the event that the onward transmission, opening or use of this message and/or any attachments adversely affects the recipient's systems or data. It is the recipient's responsibility to carry out such virus and other checks as the recipient considers appropriate.
---------------------------------------------------------
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
@ 2004-09-18 17:20 ` Christopher Browne <cbbrowne@acm.org>
2004-09-19 16:08 ` Re: How to check postgres running or not ? Jeff Eckermann <jeff_eckermann@yahoo.com>
4 siblings, 1 reply; 22+ messages in thread
From: Christopher Browne @ 2004-09-18 17:20 UTC (permalink / raw)
To: pgsql-sql
In an attempt to throw the authorities off his trail, sgaikwad@vertex.co.in ("Sandeep Gaikwad") transmitted:
> Hello Sir,
> I want to know how to check whether postgres database
> is running or not ? when I give command like ./postmaster -i &,
> whether all databases in that postgres will run or any one [default] ?
> If any one, then how to detect that database ?
Well, the way I usually check on what databases are running is thus:
cbbrowne@wolfe:/tmp/mm5/doc> netstat -an | grep PG Saturday 13:18:30
unix 2 [ ACC ] STREAM LISTENING 2793 /var/run/postgresql/.s.PGSQL.5432
One could presumably script things further to get more out of that; it
doesn't normally seem worthwhile to do so...
--
output = ("cbbrowne" "@" "ntlug.org")
http://www.ntlug.org/~cbbrowne/postgresql.html
"As long as war is regarded as wicked, it will always have
its fascination. When it is looked upon as vulgar,
it will cease to be popular."
--Oscar Wilde
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-18 17:20 ` Re: How to check postgres running or not ? Christopher Browne <cbbrowne@acm.org>
@ 2004-09-19 16:08 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
2004-09-19 21:01 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 01:04 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
0 siblings, 2 replies; 22+ messages in thread
From: Jeff Eckermann @ 2004-09-19 16:08 UTC (permalink / raw)
To: pgsql-sql
--- Christopher Browne <cbbrowne@acm.org> wrote:
> In an attempt to throw the authorities off his
> trail, sgaikwad@vertex.co.in ("Sandeep Gaikwad")
> transmitted:
> > Hello Sir,
> > I want to know how to check
> whether postgres database
> > is running or not ? when I give command like
> ./postmaster -i &,
> > whether all databases in that postgres will run or
> any one [default] ?
> > If any one, then how to detect that database ?
The "standard" way would be "pg_ctl status". "man
pg_ctl" is recommended reading for anyone
administering a PostgreSQL setup.
>
> Well, the way I usually check on what databases are
> running is thus:
>
> cbbrowne@wolfe:/tmp/mm5/doc> netstat -an | grep PG
>
> Saturday 13:18:30
> unix 2 [ ACC ] STREAM LISTENING
> 2793 /var/run/postgresql/.s.PGSQL.5432
>
> One could presumably script things further to get
> more out of that; it
> doesn't normally seem worthwhile to do so...
> --
> output = ("cbbrowne" "@" "ntlug.org")
> http://www.ntlug.org/~cbbrowne/postgresql.html
> "As long as war is regarded as wicked, it will
> always have
> its fascination. When it is looked upon as vulgar,
> it will cease to be popular."
> --Oscar Wilde
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
> (send "unregister YourEmailAddressHere" to
> majordomo@postgresql.org)
>
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-18 17:20 ` Re: How to check postgres running or not ? Christopher Browne <cbbrowne@acm.org>
2004-09-19 16:08 ` Re: How to check postgres running or not ? Jeff Eckermann <jeff_eckermann@yahoo.com>
@ 2004-09-19 21:01 ` Gaetano Mendola <mendola@bigfoot.com>
1 sibling, 0 replies; 22+ messages in thread
From: Gaetano Mendola @ 2004-09-19 21:01 UTC (permalink / raw)
To: Jeff Eckermann <jeff_eckermann@yahoo.com>
Jeff Eckermann wrote:
> --- Christopher Browne <cbbrowne@acm.org> wrote:
>
>
>>In an attempt to throw the authorities off his
>>trail, sgaikwad@vertex.co.in ("Sandeep Gaikwad")
>>transmitted:
>>
>>>Hello Sir,
>>> I want to know how to check
>>
>>whether postgres database
>>
>>>is running or not ? when I give command like
>>
>>./postmaster -i &,
>>
>>>whether all databases in that postgres will run or
>>
>>any one [default] ?
>>
>>>If any one, then how to detect that database ?
>
>
> The "standard" way would be "pg_ctl status". "man
> pg_ctl" is recommended reading for anyone
> administering a PostgreSQL setup.
Is not enough because it check only for the postmaster.pid
and not if the engine is really up.
Regards
Gaetano Mendola
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-18 17:20 ` Re: How to check postgres running or not ? Christopher Browne <cbbrowne@acm.org>
2004-09-19 16:08 ` Re: How to check postgres running or not ? Jeff Eckermann <jeff_eckermann@yahoo.com>
@ 2004-09-20 01:04 ` Worik <worik@noggon.com>
2004-09-20 01:11 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 22+ messages in thread
From: Worik @ 2004-09-20 01:04 UTC (permalink / raw)
To: Jeff Eckermann <jeff_eckermann@yahoo.com>; +Cc: pgsql-sql
Perhaps I have a bug in pg_ctrl?
This is what I get...
worik@stolberg:~$ ps aux | grep postmaster | grep -v grep
;/usr/lib/postgresql/bin/pg_ctl status
postgres 670 0.0 0.6 8544 1688 pts/1 S 12:33 0:00
/usr/lib/postgresql/bin/postmaster
pg_ctl: postmaster or postgres is not running
worik@stolberg:~$
cheers
Worik
Jeff Eckermann wrote:
> --- Christopher Browne <cbbrowne@acm.org> wrote:
>
>
>>In an attempt to throw the authorities off his
>>trail, sgaikwad@vertex.co.in ("Sandeep Gaikwad")
>>transmitted:
>>
>>>Hello Sir,
>>> I want to know how to check
>>
>>whether postgres database
>>
>>>is running or not ? when I give command like
>>
>>./postmaster -i &,
>>
>>>whether all databases in that postgres will run or
>>
>>any one [default] ?
>>
>>>If any one, then how to detect that database ?
>
>
> The "standard" way would be "pg_ctl status". "man
> pg_ctl" is recommended reading for anyone
> administering a PostgreSQL setup.
>
>
>>Well, the way I usually check on what databases are
>>running is thus:
>>
>>cbbrowne@wolfe:/tmp/mm5/doc> netstat -an | grep PG
>>
>> Saturday 13:18:30
>>unix 2 [ ACC ] STREAM LISTENING
>>2793 /var/run/postgresql/.s.PGSQL.5432
>>
>>One could presumably script things further to get
>>more out of that; it
>>doesn't normally seem worthwhile to do so...
>>--
>>output = ("cbbrowne" "@" "ntlug.org")
>>http://www.ntlug.org/~cbbrowne/postgresql.html
>>"As long as war is regarded as wicked, it will
>>always have
>> its fascination. When it is looked upon as vulgar,
>> it will cease to be popular."
>> --Oscar Wilde
>>
>>---------------------------(end of
>>broadcast)---------------------------
>>TIP 2: you can get off all lists at once with the
>>unregister command
>> (send "unregister YourEmailAddressHere" to
>>majordomo@postgresql.org)
>>
>
>
>
>
>
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match
>
>
>
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-18 17:20 ` Re: How to check postgres running or not ? Christopher Browne <cbbrowne@acm.org>
2004-09-19 16:08 ` Re: How to check postgres running or not ? Jeff Eckermann <jeff_eckermann@yahoo.com>
2004-09-20 01:04 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
@ 2004-09-20 01:11 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 22+ messages in thread
From: Tom Lane @ 2004-09-20 01:11 UTC (permalink / raw)
To: Worik <worik@noggon.com>; +Cc: Jeff Eckermann <jeff_eckermann@yahoo.com>; pgsql-sql
Worik <worik@noggon.com> writes:
> Perhaps I have a bug in pg_ctrl?
More likely you have the wrong value of PGDATA in your environment
(where "wrong" means "not what that postmaster is using").
regards, tom lane
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
@ 2004-09-18 18:36 ` Gaetano Mendola <mendola@bigfoot.com>
4 siblings, 0 replies; 22+ messages in thread
From: Gaetano Mendola @ 2004-09-18 18:36 UTC (permalink / raw)
To: pgsql-sql
Sandeep Gaikwad wrote:
>
> Hello Sir,
> I want to know how to check whether postgres database is
> running or not ? when I give command like ./postmaster -i &, whether
> all databases in that postgres will run or any one [default] ? If any
> one, then how to detect that database ?
Well, in the $DATADIR you habe postmaster.pid that contains the supposed pid...
Regards
Gaetano Mendola
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
@ 2004-09-19 01:57 ` Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
4 siblings, 1 reply; 22+ messages in thread
From: Worik @ 2004-09-19 01:57 UTC (permalink / raw)
To: Sandeep Gaikwad <sgaikwad@vertex.co.in>; +Cc: pgsql-sql
Assuming it is unix.... The command
ps xau|grep post
If it is running it will produce output like...
worik@stolberg:~$ ps xau|grep post
postgres 880 0.0 0.2 8580 740 ? S Sep07 0:31
/usr/lib/postgresql/bin/postmaster
postgres 887 0.0 0.2 9536 612 ? S Sep07 0:02 postgres:
stats buffer process
postgres 889 0.0 0.2 8624 632 ? S Sep07 0:05 postgres:
stats collector process
worik 25927 0.0 0.2 1612 540 pts/10 S 13:54 0:00 grep post
worik@stolberg:~$
If it is not running it will produce output like...
worik@stolberg:~$ ps xau|grep post
worik 26094 0.0 0.2 1608 528 pts/10 S 13:55 0:00 grep post
Sandeep Gaikwad wrote:
>
> Hello Sir,
> I want to know how to check whether postgres database is
> running or not ? when I give command like ./postmaster -i &, whether
> all databases in that postgres will run or any one [default] ? If any
> one, then how to detect that database ?
>
> Thanks and regards,
> Sandeep.
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------
>
> Disclaimer:
>
> The contents of this message are confidential and intended to the addressee at the specified e-mail address only. Its contents may not be copied or disclosed to anyone other than the intended recipient. If this e-mail is received in error, please contact Vertex Software Pvt. Ltd immediately on +91 20 4041500 with details of the sender and addressee and delete the e-mail. Vertex Software Pvt. Ltd accepts no responsibility in the event that the onward transmission, opening or use of this message and/or any attachments adversely affects the recipient's systems or data. It is the recipient's responsibility to carry out such virus and other checks as the recipient considers appropriate.
>
> ---------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
@ 2004-09-19 12:01 ` Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 22+ messages in thread
From: Geoffrey @ 2004-09-19 12:01 UTC (permalink / raw)
To: pgsql-sql
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.
--
Until later, Geoffrey Registered Linux User #108567
AT&T Certified UNIX System Programmer - 1995
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
@ 2004-09-19 16:25 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 16:57 ` Re: How to check postgres running or not ? Andrew Sullivan <ajs@crankycanuck.ca>
2004-09-19 20:57 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
0 siblings, 2 replies; 22+ messages in thread
From: Tom Lane @ 2004-09-19 16:25 UTC (permalink / raw)
To: Geoffrey <esoteric@3times25.net>; +Cc: pgsql-sql
Geoffrey <esoteric@3times25.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
"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
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
@ 2004-09-19 16:57 ` Andrew Sullivan <ajs@crankycanuck.ca>
2004-09-19 17:12 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 22+ messages in thread
From: Andrew Sullivan @ 2004-09-19 16:57 UTC (permalink / raw)
To: pgsql-sql
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.
A
--
Andrew Sullivan | ajs@crankycanuck.ca
In the future this spectacle of the middle classes shocking the avant-
garde will probably become the textbook definition of Postmodernism.
--Brad Holland
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 16:57 ` Re: How to check postgres running or not ? Andrew Sullivan <ajs@crankycanuck.ca>
@ 2004-09-19 17:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-09-20 00:20 ` Re: How to check postgres running or not ? Andrew Sullivan <ajs@crankycanuck.ca>
2004-09-20 12:19 ` Re: How to check postgres running or not ? Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 2 replies; 22+ messages in thread
From: Tom Lane @ 2004-09-19 17:12 UTC (permalink / raw)
To: Andrew Sullivan <ajs@crankycanuck.ca>; +Cc: pgsql-sql
Andrew Sullivan <ajs@crankycanuck.ca> 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
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 16:57 ` Re: How to check postgres running or not ? Andrew Sullivan <ajs@crankycanuck.ca>
2004-09-19 17:12 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
@ 2004-09-20 00:20 ` Andrew Sullivan <ajs@crankycanuck.ca>
1 sibling, 0 replies; 22+ messages in thread
From: Andrew Sullivan @ 2004-09-20 00:20 UTC (permalink / raw)
To: pgsql-sql
On Sun, Sep 19, 2004 at 01:12:07PM -0400, Tom Lane wrote:
> > 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.
Oops, good point. (And in any case, on Solaris you also have the ucb
ps, so it makes no difference.)
A
--
Andrew Sullivan | ajs@crankycanuck.ca
The fact that technology doesn't work is no bar to success in the marketplace.
--Philip Greenspun
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 16:57 ` Re: How to check postgres running or not ? Andrew Sullivan <ajs@crankycanuck.ca>
2004-09-19 17:12 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
@ 2004-09-20 12:19 ` Bruce Momjian <pgman@candle.pha.pa.us>
1 sibling, 0 replies; 22+ messages in thread
From: Bruce Momjian @ 2004-09-20 12:19 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andrew Sullivan <ajs@crankycanuck.ca>; pgsql-sql
Tom Lane wrote:
> 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.
Is improving this a TODO item for pg_ctl?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
@ 2004-09-19 20:57 ` Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 00:34 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
1 sibling, 1 reply; 22+ messages in thread
From: Gaetano Mendola @ 2004-09-19 20:57 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>
Tom Lane wrote:
> Geoffrey <esoteric@3times25.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
> "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).
Just to enforce the test is better looking for the entire executable path:
ps aux | grep /usr/bin/postmaster | grep -v grep
Regards
Gaetano Mendola
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 20:57 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
@ 2004-09-20 00:34 ` Worik <worik@noggon.com>
2004-09-20 01:33 ` Re: How to check postgres running or not ? Christopher Browne <cbbrowne@acm.org>
2004-09-20 10:05 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
0 siblings, 2 replies; 22+ messages in thread
From: Worik @ 2004-09-20 00:34 UTC (permalink / raw)
To: Gaetano Mendola <mendola@bigfoot.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-sql
[snip]
>
>
> Just to enforce the test is better looking for the entire executable path:
>
> ps aux | grep /usr/bin/postmaster | grep -v grep
>
Does not work for me!
worik@stolberg:~$ ps aux | grep /usr/bin/postmaster | grep -v grep
worik@stolberg:~$ ps aux | grep postmaster | grep -v grep
postgres 670 0.1 0.6 8544 1688 pts/1 S 12:33 0:00
/usr/lib/postgresql/bin/postmaster
worik@stolberg:~$
So...
" ps aux | grep postmaster | grep -v grep "
is more reliable(?)
cheers
Worik
>
>
> Regards
> Gaetano Mendola
>
>
>
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>
>
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 20:57 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 00:34 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
@ 2004-09-20 01:33 ` Christopher Browne <cbbrowne@acm.org>
1 sibling, 0 replies; 22+ messages in thread
From: Christopher Browne @ 2004-09-20 01:33 UTC (permalink / raw)
To: pgsql-sql
Clinging to sanity, worik@noggon.com (Worik) mumbled into her beard:
> [snip]
>> Just to enforce the test is better looking for the entire executable
>> path:
>> ps aux | grep /usr/bin/postmaster | grep -v grep
>>
>
> Does not work for me!
>
> worik@stolberg:~$ ps aux | grep /usr/bin/postmaster | grep -v grep
> worik@stolberg:~$ ps aux | grep postmaster | grep -v grep
> postgres 670 0.1 0.6 8544 1688 pts/1 S 12:33 0:00
> /usr/lib/postgresql/bin/postmaster
> worik@stolberg:~$
>
> So...
> " ps aux | grep postmaster | grep -v grep "
> is more reliable(?)
There's a very slightly clever modification that gets rid of the extra
grep...
Try..
[appropriate ps command for your platform] | egrep '[p]ostmaster'
That egrep _won't_ match its own command line.
--
let name="cbbrowne" and tld="ntlug.org" in String.concat "@" [name;tld];;
http://www3.sympatico.ca/cbbrowne/multiplexor.html
He doesn't have much of a reputation, or so I've heard.
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 20:57 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 00:34 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
@ 2004-09-20 10:05 ` Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 11:47 ` Re: How to check postgres running or not ? Peter Eisentraut <peter_e@gmx.net>
1 sibling, 1 reply; 22+ messages in thread
From: Gaetano Mendola @ 2004-09-20 10:05 UTC (permalink / raw)
To: Worik <worik@noggon.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Worik wrote:
|
|
| [snip]
|
|>
|>
|> Just to enforce the test is better looking for the entire executable
|> path:
|>
|> ps aux | grep /usr/bin/postmaster | grep -v grep
|>
|
| Does not work for me!
|
| worik@stolberg:~$ ps aux | grep /usr/bin/postmaster | grep -v grep
| worik@stolberg:~$ ps aux | grep postmaster | grep -v grep
| postgres 670 0.1 0.6 8544 1688 pts/1 S 12:33 0:00
| /usr/lib/postgresql/bin/postmaster
| worik@stolberg:~$
|
| So...
| " ps aux | grep postmaster | grep -v grep "
| is more reliable(?)
It only depends on your distribution, in your case:
ps aux | grep /usr/lib/postgresql/bin/postmaster | grep -v grep
consider also the if you run different postmaster version in different
location this is the only way I believe
Regards
Gaetano Mendola
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBTquC7UpzwH2SGd4RAiouAKCpvuLSspsTVXCjSLgDZ2ZKQ3gfywCg7rzl
gXkPlq9UanBNjIWpBvPXNwo=
=ZNAY
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-19 01:57 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-19 12:01 ` Re: How to check postgres running or not ? Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Re: How to check postgres running or not ? Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 20:57 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 00:34 ` Re: How to check postgres running or not ? Worik <worik@noggon.com>
2004-09-20 10:05 ` Re: How to check postgres running or not ? Gaetano Mendola <mendola@bigfoot.com>
@ 2004-09-20 11:47 ` Peter Eisentraut <peter_e@gmx.net>
0 siblings, 0 replies; 22+ messages in thread
From: Peter Eisentraut @ 2004-09-20 11:47 UTC (permalink / raw)
To: Gaetano Mendola <mendola@bigfoot.com>; +Cc: Worik <worik@noggon.com>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-sql
Am Montag, 20. September 2004 12:05 schrieb Gaetano Mendola:
> It only depends on your distribution, in your case:
>
> ps aux | grep /usr/lib/postgresql/bin/postmaster | grep -v grep
>
> consider also the if you run different postmaster version in different
> location this is the only way I believe
Or maybe simply:
$ ps -C postmaster -F
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
postgres 1172 1 0 4339 2160 0 09:14 ? 00:00:00 /usr/lib/postgresql/bin/postmaster -D /var/lib/postgres/data
postgres 1177 1172 0 2039 2776 0 09:14 ? 00:00:00 postgres: stats buffer process
postgres 1178 1177 0 1826 2048 0 09:14 ? 00:00:00 postgres: stats collector process
postgres 9935 1172 0 4443 2848 0 13:46 ? 00:00:00 postgres: pei template1 [local] idle
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
@ 2004-09-20 02:33 ` Arne Stoelck <stolck@web.de>
2004-09-20 13:46 ` Re: How to check postgres running or not ? Theodore Petrosky <tedpet5@yahoo.com>
4 siblings, 1 reply; 22+ messages in thread
From: Arne Stoelck @ 2004-09-20 02:33 UTC (permalink / raw)
To: Sandeep Gaikwad <sgaikwad@vertex.co.in>; +Cc: pgsql-sql
How about a simple
" telnet localhost 5432 " ?
assuming postmaster is listening on that host and port
On Fri, 17 Sep 2004, Sandeep Gaikwad wrote:
>
> Hello Sir,
> I want to know how to check whether postgres database is
> running or not ? when I give command like ./postmaster -i &, whether all
> databases in that postgres will run or any one [default] ? If any one, then
> how to detect that database ?
>
> Thanks and regards,
> Sandeep.
>
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-20 02:33 ` Re: How to check postgres running or not ? Arne Stoelck <stolck@web.de>
@ 2004-09-20 13:46 ` Theodore Petrosky <tedpet5@yahoo.com>
0 siblings, 0 replies; 22+ messages in thread
From: Theodore Petrosky @ 2004-09-20 13:46 UTC (permalink / raw)
To: Arne Stoelck <stolck@web.de>; Sandeep Gaikwad <sgaikwad@vertex.co.in>; +Cc: pgsql-sql
Funny... I set up a little program on my development
machine that queries for the rendezvous name. This way
I know my development machine is running before I try
to connect.
I think zeroconf could be used for this quite
easily...
JMHO
Ted
--- Arne Stoelck <stolck@web.de> wrote:
>
> How about a simple
>
> " telnet localhost 5432 " ?
>
> assuming postmaster is listening on that host and
> port
>
>
> On Fri, 17 Sep 2004, Sandeep Gaikwad wrote:
>
> >
> > Hello Sir,
> > I want to know how to check whether
> postgres database is
> > running or not ? when I give command like
> ./postmaster -i &, whether all
> > databases in that postgres will run or any one
> [default] ? If any one, then
> > how to detect that database ?
> >
> > Thanks and regards,
> > Sandeep.
> >
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose
> an index scan if your
> joining column's datatypes do not match
>
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
^ permalink raw reply [nested|flat] 22+ messages in thread
* Re: How to check postgres running or not ?
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
@ 2004-09-20 07:20 ` Reiner Dassing <dassing@wettzell.ifag.de>
4 siblings, 0 replies; 22+ messages in thread
From: Reiner Dassing @ 2004-09-20 07:20 UTC (permalink / raw)
To: Sandeep Gaikwad <sgaikwad@vertex.co.in>; +Cc: pgsql-sql
Hello!
Our check procedure on TRU64 UNIX is:
checkmasterdaemon
if [ $? -eq 1 ]; then
# Try to connect to postgres by selecting tables
TABELLEN=`/pg/postgresql-7.4.3/bin/psql -h postgres -c 'select datname from pg_database' postgres postgres 2>/dev/null`
if [[ "X$TABELLEN" = "X" ]];then
echo "check failed for postmaster"
exit 1
else
# echo "postmaster is running"
fi
else
echo "check failed for postmaster"
exit 1
fi
where :
checkmasterdaemon () {
MASTER_PID=$(getmasterpid)
if [ "X$MASTER_PID" = "X" ]; then
#echo "Postmaster is not running"
ret=0
else
PS_OUT=`ps -o comm,pid -p "${MASTER_PID}"`
PID=`echo $PS_OUT | awk '/postgres/ {print $4}'`
#echo $PID
if [ "X$MASTER_PID" != "X$PID" ]
then
#echo "Postmaster (${MASTER_PID}) does not exist (any more)"
ret=0
else
ret=1
fi
fi
return $ret
}
getmasterpid () {
if [[ -r ${PIDFILE} ]]
then
MASTER_PID=`head -n 1 ${PIDFILE}`
echo $MASTER_PID
else
echo ""
fi
}
--
Mit freundlichen Gruessen / With best regards
Reiner Dassing
^ permalink raw reply [nested|flat] 22+ messages in thread
end of thread, other threads:[~2004-09-20 13:46 UTC | newest]
Thread overview: 22+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-17 05:18 How to check postgres running or not ? Sandeep Gaikwad <sgaikwad@vertex.co.in>
2004-09-18 17:20 ` Christopher Browne <cbbrowne@acm.org>
2004-09-19 16:08 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
2004-09-19 21:01 ` Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 01:04 ` Worik <worik@noggon.com>
2004-09-20 01:11 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-09-18 18:36 ` Gaetano Mendola <mendola@bigfoot.com>
2004-09-19 01:57 ` Worik <worik@noggon.com>
2004-09-19 12:01 ` Geoffrey <esoteric@3times25.net>
2004-09-19 16:25 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-09-19 16:57 ` Andrew Sullivan <ajs@crankycanuck.ca>
2004-09-19 17:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-09-20 00:20 ` Andrew Sullivan <ajs@crankycanuck.ca>
2004-09-20 12:19 ` Bruce Momjian <pgman@candle.pha.pa.us>
2004-09-19 20:57 ` Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 00:34 ` Worik <worik@noggon.com>
2004-09-20 01:33 ` Christopher Browne <cbbrowne@acm.org>
2004-09-20 10:05 ` Gaetano Mendola <mendola@bigfoot.com>
2004-09-20 11:47 ` Peter Eisentraut <peter_e@gmx.net>
2004-09-20 02:33 ` Arne Stoelck <stolck@web.de>
2004-09-20 13:46 ` Theodore Petrosky <tedpet5@yahoo.com>
2004-09-20 07:20 ` Reiner Dassing <dassing@wettzell.ifag.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox