Checking whether postgresql is running

Поиск
Список
Период
Сортировка
От Ennio-Sr
Тема Checking whether postgresql is running
Дата
Msg-id 20040823135940.GA25265@deby.ei.hnet
обсуждение исходный текст
Ответы Re: Checking whether postgresql is running  (Carlos Moreno <moreno@mochima.com>)
Список pgsql-general
[Possible duplicate: original sent to novice never got through! -;(]
Hi all!
Testing a script where I need to make sure that postgresql is running
before passing a <psql dbasename -c "insert into ..." > instruction I
faced this curious behaviour:

This is the relevant content of the script:
------------------
#!/bin/bash
/usr/lib/postgresql/bin/pg_ctl status -D /var/lib/postgres/data >/dev/null 2>&1
rtn=$?
if [ $rtn -ne 0 ]; then
   echo "not running"
else
   echo "ok ok"
fi

Now, if I run the script as root, I get:

ok ok

(or, commenting the script if condition:
pg_ctl: postmaster is running (pid: 18658)
Command line was:
/usr/lib/postgresql/bin/postmasteir)

whereas, if I run the same script as ordinary user, the answer is:

not running

(or, commenting the if lines:
pg_ctl: postmaster or postgres is not running)

--------------
Everything is being tested on the same PC [running PG 7.2.1-2Woody5
under GNU/Linux, k. 2.2.22], root being on /dev/tty1, user on
/dev/tty2, and postgresql not being stopped while switching from root
to user :-).
Could anybody throw some light on this issue?
Thanks for your attention,
    Ennio.


--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo.     \\?//
 Fa' qualche cosa di cui non sei capace!"   (diceva Henry Miller) ]     (°|°)
[Why to use Win$ozz (I say) if ... "even a fool can do that.             )=(
 Do something you aren't good at!" (used to say Henry Miller) ]

--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo.     \\?//
 Fa' qualche cosa di cui non sei capace!"   (diceva Henry Miller) ]     (°|°)
[Why to use Win$ozz (I say) if ... "even a fool can do that.             )=(
 Do something you aren't good at!" (used to say Henry Miller) ]

В списке pgsql-general по дате отправления:

Предыдущее
От: Secrétariat
Дата:
Сообщение: Re: No connection to a PG 8.0 Beta 1 win32 server
Следующее
От: "Cornelia Boenigk"
Дата:
Сообщение: Re: Problem to connect to the Windows Port