Обсуждение: Creating Log file - run in background.

Поиск
Список
Период
Сортировка

Creating Log file - run in background.

От
Sterling
Дата:
H-

I am going through the source version of the postgres install. I have
successfully executed the instructions in the INSTALL file without
errors up to this point.
I don't want postgres to display it's data and processing during every
execution of a sql and as someone mentioned I should put it to a log
file.
I originally did this line.

nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
</dev/null >>server.log 2>>1 &

And it said the same thing as below. So I figure that I'd touch the
server.log file just in case it was looking for it. But as you can see
it did the same error.

[postgres@XXXX src]$ touch /usr/local/pgsql/data/server.log
[postgres@XXXX src]$ nohup /usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data </dev/null >>server.log 2>>1 &
[1] 13697
[postgres@XXXX src]$ bash: server.log: Permission denied

[1]+  Exit 1                  nohup /usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data </dev/null >>server.log 2>>1
[postgres@XXXX src]$

Here is the params on the file.
-rw-rw-r--    1 postgres postgres        0 Dec 12 19:07
/usr/local/pgsql/data/server.log


What could be the problem? Is there another way to put postgres in the
background and still keep a log file of errors? I saw the -S option but
it didn't provide for a log file.

Also, what is nohup?

Thanks for any assistance anyone could provide.
-Sterling




Re: Creating Log file - run in background.

От
Chris
Дата:
Hi,

Try putting the full path to server.log instead. So,
/usr/local/pgsql/data/server.log

Without this, it tries to write the log to the current directory.

HTH,
Regards,


>[postgres@XXXX src]$ bash: server.log: Permission denied
>
>[1]+  Exit 1                  nohup /usr/local/pgsql/bin/postmaster -D
>/usr/local/pgsql/data </dev/null >>server.log 2>>1
>[postgres@XXXX src]$
>
>Here is the params on the file.
>-rw-rw-r--    1 postgres postgres        0 Dec 12 19:07
>/usr/local/pgsql/data/server.log

------------------------
Chris Smith
http://www.squiz.net


Re: Creating Log file - run in background.

От
Sterling
Дата:
H-

I don't understand.

Isn't that what that command is doing? It contains the server.log path,
except for all that <dev/null> stuff. What is that for?

Should the command look like this than:
nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data/server.log &

Could you please clarify?
Thanks.
-Sterling


Chris wrote:

> Hi,
>
> Try putting the full path to server.log instead. So,
> /usr/local/pgsql/data/server.log
>
> Without this, it tries to write the log to the current directory.
>
> HTH,
> Regards,
>
> >[postgres@XXXX src]$ bash: server.log: Permission denied
> >
> >[1]+  Exit 1                  nohup /usr/local/pgsql/bin/postmaster -D
> >/usr/local/pgsql/data </dev/null >>server.log 2>>1
> >[postgres@XXXX src]$
> >
> >Here is the params on the file.
> >-rw-rw-r--    1 postgres postgres        0 Dec 12 19:07
> >/usr/local/pgsql/data/server.log
>
> ------------------------
> Chris Smith
> http://www.squiz.net


Re: Creating Log file - run in background.

От
Chris
Дата:
Hi,

>I don't understand.
>
>Isn't that what that command is doing? It contains the server.log path,
>except for all that <dev/null> stuff. What is that for?

/usr/local/pgsql/bin/postmaster -D
 > >/usr/local/pgsql/data </dev/null >>server.log 2>>1

These are the paths to the programs.. It just doesn't know where to put the
log. Depending on where you run it from, it will try to write the log file
to that directory. eg. If it's being run from a startup script (eg
/etc/rc.d/* <- depending on version/distribution) it will try to write to
/etc/rc.d/*.. which it's not allowed to do.

>Should the command look like this than:
>nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data/server.log &

That should work, yep.

HTH,

------------------------
Chris Smith
http://www.squiz.net


Re: Creating Log file - run in background.

От
Tom Lane
Дата:
>> Should the command look like this than:
>> nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data/server.log &

> That should work, yep.

Uh, nope.

That will try to use /usr/local/pgsql/data/server.log as a directory.

Your original advice was better.

            regards, tom lane

Re: Creating Log file - run in background.

От
Chris
Дата:
Oops, thanks. I misread it.

after all that, it should be
nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
</dev/null >> /usr/local/pgsql/logs/server.log 2>>1 &

where logs = your pgsql log directory :)

> >> Should the command look like this than:
> >> nohup /usr/local/pgsql/bin/postmaster -D
> /usr/local/pgsql/data/server.log &
>
> > That should work, yep.
>
>Uh, nope.
>
>That will try to use /usr/local/pgsql/data/server.log as a directory.
>
>Your original advice was better.
>
>                         regards, tom lane


------------------------
Chris Smith
http://www.squiz.net


Re: Creating Log file - run in background.

От
Sterling
Дата:
H-

Ok. So the new command should look like this.

nohup /usr/local/pgsql/bin/postmaster -D  > >/usr/local/pgsql/data </dev/null
>>/usr/local/pgsql/data/server.log 2>>1 &

What are the > > 's for? Are they acting as ( ) 's like in perl or some other
language?

If so should they match? I'm getting lost in the > > and can't figure out if the >
> is actually in the command or part of the wrapping for my window terminal (it
stays when I resize the window so...)  or from my email client when it copies the
original post.

Thanks for all your help and replies. I just need to get up to speed on what
you're telling me. 8^)
-Sterling


Tom Lane wrote:

> >> Should the command look like this than:
> >> nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data/server.log &
>
> > That should work, yep.
>
> Uh, nope.
>
> That will try to use /usr/local/pgsql/data/server.log as a directory.
>
> Your original advice was better.
>
>                         regards, tom lane


Re: Creating Log file - run in background.

От
John Burski
Дата:
It looks like the "> >" between the "-D" (postmaster command line option) and the
"/usr/local/pgsql/data" filename are continuations in your e-mail window.

The ">>" between the "/dev/null" filename and the "/user/local/.../server.log"
filename are meant to redirect the output to stdout (standard output, usually the
screen) and append it the file name that follows, in this case
"/usr/local/.../server.log".

Here's what the command is supposed to do:

     nohup - Execute the following command, making it immune to "hangups" and
     with output to a non-tty device.

     /usr/local/.../postmaster -D /usr/local/pgsql/data - Execute the postmaster
     program, using /usr/local/pgsql/data directory as the root of the tree of
     database directories.

     < /dev/null - Input is redirected from the bit-bucket.  (Don't ask me why -
     I've not looked closely enough at the nitty-gritty to understand that yet).

     >> /usr/local/pgsql/data/server.log - Redirect anything output to stdout to
     this file.

     2>>1 - Redirect and append anything output to stderr to stdout.  This
     causes both stdout and stderr to be logged in the same file

     & - Run in the background.

Hope that helps.

Regards.

Sterling wrote:

> H-
>
> Ok. So the new command should look like this.
>
> nohup /usr/local/pgsql/bin/postmaster -D  > >/usr/local/pgsql/data </dev/null
> >>/usr/local/pgsql/data/server.log 2>>1 &
>
> What are the > > 's for? Are they acting as ( ) 's like in perl or some other
> language?
>
> If so should they match? I'm getting lost in the > > and can't figure out if the >
> > is actually in the command or part of the wrapping for my window terminal (it
> stays when I resize the window so...)  or from my email client when it copies the
> original post.
>
> Thanks for all your help and replies. I just need to get up to speed on what
> you're telling me. 8^)
> -Sterling
>
> Tom Lane wrote:
>
> > >> Should the command look like this than:
> > >> nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data/server.log &
> >
> > > That should work, yep.
> >
> > Uh, nope.
> >
> > That will try to use /usr/local/pgsql/data/server.log as a directory.
> >
> > Your original advice was better.
> >
> >                         regards, tom lane

--
John Burski
Chief IT Cook and Bottlewasher
911 Emergency Products, St. Cloud, MN
(320) 656 0076




Re: Creating Log file - run in background.

От
ghaverla@freenet.edmonton.ab.ca
Дата:
On Thu, 14 Dec 2000, John Burski wrote:

> Here's what the command is supposed to do:
>
>      nohup - Execute the following command, making it immune to "hangups" and
>      with output to a non-tty device.

Comes from hanging up the phone line connection to your computer.
nohup => NO Hang UP

>      < /dev/null - Input is redirected from the bit-bucket.  (Don't ask me why -
>      I've not looked closely enough at the nitty-gritty to understand that yet).

When you read /dev/null, you immediately get
end of file.  Therefore, things don't get stalled
waiting for input.

>      >> /usr/local/pgsql/data/server.log - Redirect anything output to stdout to
>      this file.

Actually append.  But yes it is a redirect.

>      2>>1 - Redirect and append anything output to stderr to stdout.  This
>      causes both stdout and stderr to be logged in the same file

stdin is known as file descriptor 0,
stdout is known as file descriptor 1,
stderr is known as file descriptor 2,

So, above "binds" stderr and stdout and redirects to file.

Gord

Matter Realisations     http://www.materialisations.com/
Gordon Haverland, B.Sc. M.Eng. President
101  9504 182 St. NW    Edmonton, AB, CA  T5T 3A7
780/481-8019            ghaverla @ freenet.edmonton.ab.ca
780/993-1274 (cell)



Re: Creating Log file - run in background.

От
John Burski
Дата:
Thanks, Gord!

You did a better job of clarifying than I did :-)

ghaverla@freenet.edmonton.ab.ca wrote:

> On Thu, 14 Dec 2000, John Burski wrote:
>
> > Here's what the command is supposed to do:
> >
> >      nohup - Execute the following command, making it immune to "hangups" and
> >      with output to a non-tty device.
>
> Comes from hanging up the phone line connection to your computer.
> nohup => NO Hang UP
>
> >      < /dev/null - Input is redirected from the bit-bucket.  (Don't ask me why -
> >      I've not looked closely enough at the nitty-gritty to understand that yet).
>
> When you read /dev/null, you immediately get
> end of file.  Therefore, things don't get stalled
> waiting for input.
>
> >      >> /usr/local/pgsql/data/server.log - Redirect anything output to stdout to
> >      this file.
>
> Actually append.  But yes it is a redirect.
>
> >      2>>1 - Redirect and append anything output to stderr to stdout.  This
> >      causes both stdout and stderr to be logged in the same file
>
> stdin is known as file descriptor 0,
> stdout is known as file descriptor 1,
> stderr is known as file descriptor 2,
>
> So, above "binds" stderr and stdout and redirects to file.
>
> Gord
>
> Matter Realisations     http://www.materialisations.com/
> Gordon Haverland, B.Sc. M.Eng. President
> 101  9504 182 St. NW    Edmonton, AB, CA  T5T 3A7
> 780/481-8019            ghaverla @ freenet.edmonton.ab.ca
> 780/993-1274 (cell)

--
John Burski
Chief IT Cook and Bottlewasher
911 Emergency Products, St. Cloud, MN
(320) 656 0076

++++++++++++++++++++++++++++++++++
+ How's your cheese holding out? +
++++++++++++++++++++++++++++++++++




Re: Creating Log file - run in background.

От
Sterling
Дата:
H-

Thanks for the detailed information. Explainations are always welcome. I understand a
lot more about what it's trying to do now that I know what it's suppose to do. 8^)

Well based on all the input I've gotten I did some things.

Here is the command that I came up with to run:
nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data <
/dev/null>>/usr/local/pgsql/data/server.log 2>> 1&

I'm running this command as postgres user. I'm still getting this error message when
attempting to run the command.
[postgres@XXXX local]$ nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data <
/dev/null>>/usr/local/pgsql/data/server.log 2>> 1&
[1] 14869
[postgres@XXXX local]$ bash: 1: Permission denied
[1]+  Exit 1                  nohup /usr/local/pgsql/bin/postmaster -D
/usr/local/pgsql/data </dev/null >>/usr/local/pgsql/data/server.log 2>>1

Thinking that it might be a permission issue I did:

chown -R postgres.postgres /usr/local/pgsql

that directory and removed the server.log file I touched before.
On a good note it's creating that file. Here's what it said.
less server.log
/bin/bash: /home/XXXX/.bashrc: Permission denied

This makes me think it might be some things that are set up in my bashrc. But what could
that be? I installed and compiled the code without problems. Of course I did it as root.

Perhaps I'm going about this the wrong way. Is there some other command I can use to get
this process working?

Not even the basic command will start postgres now.
[postgres@XXXX data]$ /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
DEBUG:  Data Base System is starting up at Thu Dec 14 16:34:10 2000
DEBUG:  Data Base System was shut down at Thu Dec 14 16:33:21 2000
DEBUG:  Data Base System is in production state at Thu Dec 14 16:34:10 2000
Fast Shutdown request at Thu Dec 14 16:34:18 2000
DEBUG:  Data Base System shutting down at Thu Dec 14 16:34:18 2000
DEBUG:  Data Base System shut down at Thu Dec 14 16:34:18 2000

What's this?

Sorry for extended delay in replying but I had to re-subscribe to the list. For some
reason it dropped me. Maybe I sent too many emails. 8^)

Well thanks for any info you might have. The learning continues.
-Sterling



John Burski wrote:

> It looks like the "> >" between the "-D" (postmaster command line option) and the
> "/usr/local/pgsql/data" filename are continuations in your e-mail window.
>
> The ">>" between the "/dev/null" filename and the "/user/local/.../server.log"
> filename are meant to redirect the output to stdout (standard output, usually the
> screen) and append it the file name that follows, in this case
> "/usr/local/.../server.log".
>
> Here's what the command is supposed to do:
>
>      nohup - Execute the following command, making it immune to "hangups" and
>      with output to a non-tty device.
>
>      /usr/local/.../postmaster -D /usr/local/pgsql/data - Execute the postmaster
>      program, using /usr/local/pgsql/data directory as the root of the tree of
>      database directories.
>
>      < /dev/null - Input is redirected from the bit-bucket.  (Don't ask me why -
>      I've not looked closely enough at the nitty-gritty to understand that yet).
>
>      >> /usr/local/pgsql/data/server.log - Redirect anything output to stdout to
>      this file.
>
>      2>>1 - Redirect and append anything output to stderr to stdout.  This
>      causes both stdout and stderr to be logged in the same file
>
>      & - Run in the background.
>
> Hope that helps.
>
> Regards.
>
> Sterling wrote:
>
> > H-
> >
> > Ok. So the new command should look like this.
> >
> > nohup /usr/local/pgsql/bin/postmaster -D  > >/usr/local/pgsql/data </dev/null
> > >>/usr/local/pgsql/data/server.log 2>>1 &
> >
> > What are the > > 's for? Are they acting as ( ) 's like in perl or some other
> > language?
> >
> > If so should they match? I'm getting lost in the > > and can't figure out if the >
> > > is actually in the command or part of the wrapping for my window terminal (it
> > stays when I resize the window so...)  or from my email client when it copies the
> > original post.
> >
> > Thanks for all your help and replies. I just need to get up to speed on what
> > you're telling me. 8^)
> > -Sterling
> >
> > Tom Lane wrote:
> >
> > > >> Should the command look like this than:
> > > >> nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data/server.log &
> > >
> > > > That should work, yep.
> > >
> > > Uh, nope.
> > >
> > > That will try to use /usr/local/pgsql/data/server.log as a directory.
> > >
> > > Your original advice was better.
> > >
> > >                         regards, tom lane
>
> --
> John Burski
> Chief IT Cook and Bottlewasher
> 911 Emergency Products, St. Cloud, MN
> (320) 656 0076


Re: Creating Log file - run in background.

От
Sterling
Дата:
H-

Thank you.

Unforunately I already checked on that and for some reason I don't have a postgresql in my rc.d/init.d directory.

Perhaps it's because I compiled the postgress from source code. I'm using 7.0.3. Redhat 6.2 Kernel 2.2.14-5.0 on an
i586.

I think I'll go through the compiling again (since there's no way to track down every file during any install unless
youuse 
RPM) and see how it goes from there. I'd like to remove it first and than try again, but I don't think that's possible
with
a source compile. Am I wrong?

I appreciate all the support and information you've sent. I'll post again in a day or so and see how it goes from
there.
Unless success follows quickly.

What would be the harm in installing a postgres RPM version over top a source code compile? Would that be bad? Just
grasping
here.

Thanks and have a good day.
-Sterling


John Burski wrote:

> I don't recall which disto you're using, but Red Hat usually has a startup script for
> postgreql in the /etc/rc.d/init.d directory.  To use it you simple "su" to root, and issue
> the command
>
>      /etc/rc.d/init.d/postgresql start
>
> The script takes care of the details.  I've attached the script file - if you study it I
> think you'll gain some insights.
>
> Regards.
>
> Sterling wrote:
>
> > H-
> >
> > Thanks for the detailed information. Explainations are always welcome. I understand a
> > lot more about what it's trying to do now that I know what it's suppose to do. 8^)
> >
> > Well based on all the input I've gotten I did some things.
> >
> > Here is the command that I came up with to run:
> > nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data <
> > /dev/null>>/usr/local/pgsql/data/server.log 2>> 1&
> >
> > I'm running this command as postgres user. I'm still getting this error message when
> > attempting to run the command.
> > [postgres@XXXX local]$ nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data <
> > /dev/null>>/usr/local/pgsql/data/server.log 2>> 1&
> > [1] 14869
> > [postgres@XXXX local]$ bash: 1: Permission denied
> > [1]+  Exit 1                  nohup /usr/local/pgsql/bin/postmaster -D
> > /usr/local/pgsql/data </dev/null >>/usr/local/pgsql/data/server.log 2>>1
> >
> > Thinking that it might be a permission issue I did:
> >
> > chown -R postgres.postgres /usr/local/pgsql
> >
> > that directory and removed the server.log file I touched before.
> > On a good note it's creating that file. Here's what it said.
> > less server.log
> > /bin/bash: /home/XXXX/.bashrc: Permission denied
> >
> > This makes me think it might be some things that are set up in my bashrc. But what could
> > that be? I installed and compiled the code without problems. Of course I did it as root.
> >
> > Perhaps I'm going about this the wrong way. Is there some other command I can use to get
> > this process working?
> >
> > Not even the basic command will start postgres now.
> > [postgres@XXXX data]$ /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
> > DEBUG:  Data Base System is starting up at Thu Dec 14 16:34:10 2000
> > DEBUG:  Data Base System was shut down at Thu Dec 14 16:33:21 2000
> > DEBUG:  Data Base System is in production state at Thu Dec 14 16:34:10 2000
> > Fast Shutdown request at Thu Dec 14 16:34:18 2000
> > DEBUG:  Data Base System shutting down at Thu Dec 14 16:34:18 2000
> > DEBUG:  Data Base System shut down at Thu Dec 14 16:34:18 2000
> >
> > What's this?
> >
> > Sorry for extended delay in replying but I had to re-subscribe to the list. For some
> > reason it dropped me. Maybe I sent too many emails. 8^)
> >
> > Well thanks for any info you might have. The learning continues.
> > -Sterling
> >
> > John Burski wrote:
> >
> > > It looks like the "> >" between the "-D" (postmaster command line option) and the
> > > "/usr/local/pgsql/data" filename are continuations in your e-mail window.
> > >
> > > The ">>" between the "/dev/null" filename and the "/user/local/.../server.log"
> > > filename are meant to redirect the output to stdout (standard output, usually the
> > > screen) and append it the file name that follows, in this case
> > > "/usr/local/.../server.log".
> > >
> > > Here's what the command is supposed to do:
> > >
> > >      nohup - Execute the following command, making it immune to "hangups" and
> > >      with output to a non-tty device.
> > >
> > >      /usr/local/.../postmaster -D /usr/local/pgsql/data - Execute the postmaster
> > >      program, using /usr/local/pgsql/data directory as the root of the tree of
> > >      database directories.
> > >
> > >      < /dev/null - Input is redirected from the bit-bucket.  (Don't ask me why -
> > >      I've not looked closely enough at the nitty-gritty to understand that yet).
> > >
> > >      >> /usr/local/pgsql/data/server.log - Redirect anything output to stdout to
> > >      this file.
> > >
> > >      2>>1 - Redirect and append anything output to stderr to stdout.  This
> > >      causes both stdout and stderr to be logged in the same file
> > >
> > >      & - Run in the background.
> > >
> > > Hope that helps.
> > >
> > > Regards.
> > >
> > > Sterling wrote:
> > >
> > > > H-
> > > >
> > > > Ok. So the new command should look like this.
> > > >
> > > > nohup /usr/local/pgsql/bin/postmaster -D  > >/usr/local/pgsql/data </dev/null
> > > > >>/usr/local/pgsql/data/server.log 2>>1 &
> > > >
> > > > What are the > > 's for? Are they acting as ( ) 's like in perl or some other
> > > > language?
> > > >
> > > > If so should they match? I'm getting lost in the > > and can't figure out if the >
> > > > > is actually in the command or part of the wrapping for my window terminal (it
> > > > stays when I resize the window so...)  or from my email client when it copies the
> > > > original post.
> > > >
> > > > Thanks for all your help and replies. I just need to get up to speed on what
> > > > you're telling me. 8^)
> > > > -Sterling
> > > >
> > > > Tom Lane wrote:
> > > >
> > > > > >> Should the command look like this than:
> > > > > >> nohup /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data/server.log &
> > > > >
> > > > > > That should work, yep.
> > > > >
> > > > > Uh, nope.
> > > > >
> > > > > That will try to use /usr/local/pgsql/data/server.log as a directory.
> > > > >
> > > > > Your original advice was better.
> > > > >
> > > > >                         regards, tom lane
> > >
> > > --
> > > John Burski
> > > Chief IT Cook and Bottlewasher
> > > 911 Emergency Products, St. Cloud, MN
> > > (320) 656 0076
>
> --
> John Burski
> Chief IT Cook and Bottlewasher
> 911 Emergency Products, St. Cloud, MN
> (320) 656 0076
>
> ++++++++++++++++++++++++++++++++++
> + How's your cheese holding out? +
> ++++++++++++++++++++++++++++++++++
>
>   ------------------------------------------------------------------------
> #! /bin/sh
> # postgresql    This is the init script for starting up the PostgreSQL
> #               server
>
> # Version 6.5.3-2 Lamar Owen
> # Added code to determine if PGDATA exists, whether it is current version
> #     or not, and initdb if no PGDATA (initdb will not overwrite a database).
>
> # Version 7.0 Lamar Owen
> # Added logging code
> # Changed PGDATA.
> #
>
> # Version 7.0.2 Trond Eivind Glomsrød <teg@redhat.com>
> # use functions, add conditional restart
>
> # Version 7.0.3 Lamar Owen <lamar@postgresql.org>
> # Check for the existence of functions before blindly using them
> # in particular -- check for success () and failure () before using.
> # More Cross-distribution support -- PGVERSION variable, and docdir checks.
>
> # chkconfig: 345 85 15
> # description: Starts and stops the PostgreSQL backend daemon that handles \
> #              all database requests.
> # processname: postmaster
> # pidfile: /var/run/postmaster.pid
> #
> # PGVERSION is:
> PGVERSION=7.0.3
>
> # Source function library.
> INITD=/etc/rc.d/init.d
> . $INITD/functions
>
> # Get function listing for cross-distribution logic.
> TYPESET=`typeset -f|grep "declare"`
>
> # Get config.
> . /etc/sysconfig/network
>
> # Check that networking is up.
> # Pretty much need it for postmaster.
> [ ${NETWORKING} = "no" ] && exit 0
>
> [ -f /usr/bin/postmaster ] || exit 0
>
> start(){
>         PSQL_CHECK="Checking postgresql installation: "
>         PSQL_START="Starting postgresql service: "
>
>         echo -n "$PSQL_CHECK"
>
>         # Check for older PGDATA location.
>         if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d /var/lib/pgsql/base/template1 ]
>         then
>                 export PGDATA=/var/lib/pgsql
>         else
>                 export PGDATA=/var/lib/pgsql/data
>         fi
>
>         # Check for the PGDATA structure
>         if [ -f $PGDATA/PG_VERSION ] && [ -d $PGDATA/base/template1 ]
>         then
>         # Check version of existing PGDATA
>
>                 if [ `cat $PGDATA/PG_VERSION` != '7.0' ]
>                 then
>                         SYSDOCDIR="(Your System's documentation directory)"
>                         if [ -d /usr/doc/postgresql-$PGVERSION ]
>                         then
>                                 SYSDOCDIR=/usr/doc
>                         fi
>                         if [ -d /usr/share/doc/postgresql-$PGVERSION ]
>                         then
>                                 SYSDOCDIR=/usr/share/doc
>                         fi
>                         if [ -d /usr/doc/packages/postgresql-$PGVERSION ]
>                         then
>                                 SYSDOCDIR=/usr/doc/packages
>                         fi
>                         if [ -d /usr/share/doc/packages/postgresql-$PGVERSION ]
>                         then
>                                 SYSDOCDIR=/usr/share/doc/packages
>                         fi
>                         echo
>                         echo "An old version of the database format was found."
>                         echo "You need to upgrade the data format before using PostgreSQL."
>                         echo "See $SYSDOCDIR/postgresql-$PGVERSION/README.rpm-dist for more information."
>                         exit 1
>                 else
>                         if echo "$TYPESET"|grep "declare -f success ()" >/dev/null
>                         then
>                                 success "$PSQL_CHECK"
>                         else
>                                 echo "  [ OK ]"
>                         fi
>                         echo
>                 fi
>
>         # No existing PGDATA! Initdb it.
>
>         else
>                 echo "no database files found."
>                 if [ ! -d $PGDATA ]
>                 then
>                         mkdir -p $PGDATA
>                         chown postgres.postgres $PGDATA
>                 fi
>                 su -l postgres -c '/usr/bin/initdb --pglib=/usr/lib/pgsql --pgdata=/var/lib/pgsql/data' < /dev/null
>         fi
>
>         # Check for postmaster already running...
>         pid=`pidof postmaster`
>         if [ $pid ]
>         then
>                 echo "Postmaster already running."
>         else
>                 #all systems go -- remove any stale lock files
>                 rm -f /tmp/.s.PGSQL.* > /dev/null
>                 echo -n "$PSQL_START"
>                 su -l postgres -c "/usr/bin/pg_ctl  -D $PGDATA -p /usr/bin/postmaster start >/dev/null 2>&1" <
/dev/null
>                 sleep 1
>                 pid=`pidof postmaster`
>                 if [ $pid ]
>                 then
>                         if echo "$TYPESET"|grep "declare -f success ()" >/dev/null
>                         then
>                                 success "$PSQL_START"
>                         else
>                                 echo "  [ OK ]"
>                         fi
>                         touch /var/lock/subsys/postgresql
>                         echo $pid > /var/run/postmaster.pid
>                         echo
>                 else
>                         if echo "$TYPESET"|grep "declare -f failure ()" >/dev/null
>                         then
>                                 failure "$PSQL_START"
>                         else
>                                 echo " [ FAILED ]"
>                         fi
>                         echo
>                 fi
>         fi
> }
>
> stop(){
>         echo -n "Stopping postgresql service: "
>         killproc postmaster
>         sleep 2
>         rm -f /var/run/postmaster.pid
>         rm -f /var/lock/subsys/postgresql
>         echo
> }
>
> restart(){
>         stop
>         start
> }
>
> condrestart(){
>     [ -e /var/lock/subsys/postgresql ] && restart || :
> }
>
> # This script is slightly unusual in that the name of the daemon (postmaster)
> # is not the same as the name of the subsystem (postgresql)
>
> # See how we were called.
> case "$1" in
>   start)
>         start
>         ;;
>   stop)
>         stop
>         ;;
>   status)
>         status postmaster
>         ;;
>   restart)
>         restart
>         ;;
>   condrestart)
>         condrestart
>         ;;
>   *)
>         echo "Usage: postgresql {start|stop|status|restart|condrestart}"
>         exit 1
> esac
>
> exit 0


Re: Creating Log file - run in background.

От
Sterling
Дата:
For some reason this email didn't post to the list. So I'm including it
for completeness.

H-

Ok. So the new command should look like this.

nohup /usr/local/pgsql/bin/postmaster -D  > >/usr/local/pgsql/data
</dev/null
>>/usr/local/pgsql/data/server.log 2>>1 &

What are the > > 's for? Are they acting as ( ) 's like in perl or some
other
language?

If so should they match? I'm getting lost in the > > and can't figure
out if the >
> is actually in the command or part of the wrapping for my window
terminal (it
stays when I resize the window so...)  or from my email client when it
copies the
original post.

Thanks for all your help and replies. I just need to get up to speed on
what
you're telling me. 8^)
-Sterling