Thread: pgsql.sh

pgsql.sh

From
Jonah Kuo
Date:
Hello,

First of all, I apologize if this has been discussed before.

I have this startup script 'pgsql.sh' on my FreeBSD-3.0 system,
everything goes fine except I can't have error messages send to
the file I specified in this script

#!/bin/sh
[ -x /tmp/.s.PGSQL.* ] && rm -f /tmp/.s.PGSQL.*
[ -x /usr/local/pgsql/bin/postmaster ] && {
        su -l postgres -c 'exec
    /usr/local/pgsql/bin/postmaster
    -D/usr/local/pgsql/data
    -S -o -F > /usr/local/pgsql/errlog' &
    echo -n ' pgSQL'
}

There was an /usr/local/pgsql/errlog opened, and the error messages are
always
send to console  regardless of specifying '-S' option or not.

Is there anybody encountered this before? any help would be grateful.

Jonah




Re: [ADMIN] pgsql.sh

From
Jason Boxman
Date:
On Mon, 23 Nov 1998, Jonah Kuo wrote:
>Hello,

Hey!

>First of all, I apologize if this has been discussed before.
>
>I have this startup script 'pgsql.sh' on my FreeBSD-3.0 system,
>everything goes fine except I can't have error messages send to
>the file I specified in this script
>
>#!/bin/sh
>[ -x /tmp/.s.PGSQL.* ] && rm -f /tmp/.s.PGSQL.*
>[ -x /usr/local/pgsql/bin/postmaster ] && {
>        su -l postgres -c 'exec
>    /usr/local/pgsql/bin/postmaster
>    -D/usr/local/pgsql/data
>    -S -o -F > /usr/local/pgsql/errlog' &
>    echo -n ' pgSQL'
>}
>
>There was an /usr/local/pgsql/errlog opened, and the error messages are
>always
>send to console  regardless of specifying '-S' option or not.
>
>Is there anybody encountered this before? any help would be grateful.

Just an offhand guess, but maybe you need to also redirect STERR in addition to
STOUT to /usr/local/pgsql/errlog?  Shell scripts have never been my thing, but
isn't it something like "... > /usr/local/pgsql/errlog 2>&1 &" or something
along those lines perhaps? (No since giving misinformation; I just double
checked my own init.d script and it is, in fact, correctly stated above.  Well,
after I fixed my mistake... *grin*.)

>Jonah
--

Sincerely,
Jason Boxman

uselinux@email.com
benefits@cybertechs.com

"We have lived not in proportion to the number of years we have
spent on the earth, but in proportion as we have enjoyed."
-Henry David Thoreau

Re: [ADMIN] pgsql.sh

From
Jonah Kuo
Date:
Jason Boxman wrote:

> Just an offhand guess, but maybe you need to also redirect STERR in addition to
> STOUT to /usr/local/pgsql/errlog?  Shell scripts have never been my thing, but
> isn't it something like "... > /usr/local/pgsql/errlog 2>&1 &" or something
> along those lines perhaps? (No since giving misinformation; I just double
> checked my own init.d script and it is, in fact, correctly stated above.  Well,
> after I fixed my mistake... *grin*.)
>

No matter I use "...> /usr/local/pgsql/errlog &" or
"...> /usr/local/pgsql/errlog 2>&1 &", it still send errlog to the console and
the errlog size is always zero, any further ideas?


Thanks in advance.


Jonah


Re: [ADMIN] pgsql.sh

From
Jason Boxman
Date:

On Tue, 24 Nov 1998, Jonah Kuo wrote:

> Jason Boxman wrote:
>
> > Just an offhand guess, but maybe you need to also redirect STERR in addition to
> > STOUT to /usr/local/pgsql/errlog?  Shell scripts have never been my thing, but
> > isn't it something like "... > /usr/local/pgsql/errlog 2>&1 &" or something
> > along those lines perhaps? (No since giving misinformation; I just double
> > checked my own init.d script and it is, in fact, correctly stated above.  Well,
> > after I fixed my mistake... *grin*.)
> >
>
> No matter I use "...> /usr/local/pgsql/errlog &" or
> "...> /usr/local/pgsql/errlog 2>&1 &", it still send errlog to the console and
> the errlog size is always zero, any further ideas?

Perhaps the user you're running it as (should be postgres user) doesn't
have write permissions to that directory? Can you cat >
/usr/local/pgsql/errlog and add stuff manually as the postgres user? I
don't think I can be too much more help, but I hope someone else can.

> Thanks in advance.
>
>
> Jonah
>
>


Re: [ADMIN] pgsql.sh

From
Jonah Kuo
Date:
Jason Boxman wrote:

> On Tue, 24 Nov 1998, Jonah Kuo wrote:
> Perhaps the user you're running it as (should be postgres user) doesn't
> have write permissions to that directory? Can you cat >
> /usr/local/pgsql/errlog and add stuff manually as the postgres user? I
> don't think I can be too much more help, but I hope someone else can.
>

ls -l /usr/local
...
drwxr-xr-x   8 postgres  wheel      512 Nov 11 14:56 pgsql
...

ls -l /usr/local/pgsql
drwxr-xr-x   8 postgres  wheel   512 Nov 11 14:56 .
drwxr-xr-x  22 root      wheel   512 Nov 23 12:15 ..
drwxr-xr-x   2 postgres  wheel   512 Nov 24 09:32 bin
drwxr-xr-x   3 postgres  wheel   512 Nov 11 14:58 data
drwx------   3 postgres  wheel   512 Nov 11 15:02 dataold
-rw-r--r--   1 postgres  wheel     0 Nov 11 11:41 errlog
-rw-r--r--   1 postgres  wheel     0 Sep 28 09:05 errlog.5432
drwxr-xr-x  11 postgres  wheel   512 Nov 24 09:32 include
drwxr-xr-x   2 postgres  wheel  1024 Nov 24 09:32 lib
drwxr-xr-x   6 postgres  wheel   512 Jul 13 11:56 man

Jonah


Re: [ADMIN] pgsql.sh

From
Matthew Hixson
Date:
On Mon, 23 Nov 1998, Jonah Kuo wrote:

> Hello,
>
> First of all, I apologize if this has been discussed before.
>
> I have this startup script 'pgsql.sh' on my FreeBSD-3.0 system,
> everything goes fine except I can't have error messages send to
> the file I specified in this script
>
> #!/bin/sh
> [ -x /tmp/.s.PGSQL.* ] && rm -f /tmp/.s.PGSQL.*
> [ -x /usr/local/pgsql/bin/postmaster ] && {
>         su -l postgres -c 'exec
>     /usr/local/pgsql/bin/postmaster
>     -D/usr/local/pgsql/data
>     -S -o -F > /usr/local/pgsql/errlog' &
>     echo -n ' pgSQL'
> }
>
> There was an /usr/local/pgsql/errlog opened, and the error messages are
> always
> send to console  regardless of specifying '-S' option or not.
>
> Is there anybody encountered this before? any help would be grateful.

On this line:

-S -o -F > /usr/local/pgsql/errlog' &

Modify it to look like this:

-S -o -F 2>&1 > /usr/local/pgsql/errlog' &

Assuming this script runs through bash it will direct standard error
(stderr) to standard output (stdout).  All output will be sent to
/usr/local/pgsql/errlog.

Enjoy.
  -M@

--
Matthew Hixson - CIO              Linux, n;
FroZenWave Communications           the nouveau postmodern operating
http://www.frozenwave.com           system for the masses




Re: [ADMIN] pgsql.sh

From
Jonah Kuo
Date:
Matthew Hixson wrote:

> On this line:
>
> -S -o -F > /usr/local/pgsql/errlog' &
>
> Modify it to look like this:
>
> -S -o -F 2>&1 > /usr/local/pgsql/errlog' &
>
> Assuming this script runs through bash it will direct standard error
> (stderr) to standard output (stdout).  All output will be sent to
> /usr/local/pgsql/errlog.
>
> Enjoy.
>

It still doesn't help,  I have bash installed in /usr/local/bin, then
I modified the first line to #!/usr/local/bin/bash, amd modified
the line you wrote above, then try again, then result in same.

I simply test it to see if it works as do the following, login as postgres
and enter interactive monitor,

postgres=> ls;
ERROR:  parser: parse error at or near "ls"

The same ERROR message appears on the console, and errlog size is
still 0.


Jonah


Re: [ADMIN] pgsql.sh

From
Matthew Hixson
Date:
On Tue, 24 Nov 1998, Jonah Kuo wrote:

> > -S -o -F 2>&1 > /usr/local/pgsql/errlog' &
>
> It still doesn't help,  I have bash installed in /usr/local/bin, then
> I modified the first line to #!/usr/local/bin/bash, amd modified
> the line you wrote above, then try again, then result in same.
>
> I simply test it to see if it works as do the following, login as postgres
> and enter interactive monitor,
>
> postgres=> ls;
> ERROR:  parser: parse error at or near "ls"
>
> The same ERROR message appears on the console, and errlog size is
> still 0.

I think this might be part of the problem:  from 'man postmaster'

" -S Specifies that the postmaster process should start up in silent mode.
That is, it will
            disassociate from the user's (controlling) tty and start its
own process group.  This
            should not be used in combination with debugging options
because any messages printed
            to standard output and standard error are discarded."

Another problem could be that the -o option means that the rest of the
line should be sent to the backend as commandline arguments, so it might
not be grabbing the ouput from postmaster at all.
  Here's my startup script:

echo "postmaster -B 256 >/home/postgres/pm.log 2>&1 &" | su - postgres

This is on my Slackware system.

  -M@

--
Matthew Hixson - CIO              Linux, n;
FroZenWave Communications           the nouveau postmodern operating
http://www.frozenwave.com           system for the masses




I got the answer!! -- Re: [ADMIN] pgsql.sh

From
Jonah Kuo
Date:
Matthew Hixson wrote:

> I think this might be part of the problem:  from 'man postmaster'
>
> " -S Specifies that the postmaster process should start up in silent mode.
> That is, it will
>             disassociate from the user's (controlling) tty and start its
> own process group.  This
>             should not be used in combination with debugging options
> because any messages printed
>             to standard output and standard error are discarded."
>
> Another problem could be that the -o option means that the rest of the
> line should be sent to the backend as commandline arguments, so it might
> not be grabbing the ouput from postmaster at all.
>   Here's my startup script:
>
> echo "postmaster -B 256 >/home/postgres/pm.log 2>&1 &" | su - postgres
>
> This is on my Slackware system.
>
>   -M@
>

Here is my new pgsql.sh, you can see the differences between the new one and
oringinal one.

#!/bin/sh
[ -x /tmp/.s.PGSQL.* ] && rm -f /tmp/.s.PGSQL.*
[ -x /usr/local/pgsql/bin/postmaster ] && \
        su -l postgres -c 'exec \
    /usr/local/pgsql/bin/postmaster \
    -D/usr/local/pgsql/data \
    -o -F > /usr/local/pgsql/errlog 2>&1' & \
    echo -n ' pgSQL' &

Thanks all folks who gave me the light.


Jonah