Re: Creating Log file - run in background.

From: Sterling <smullett(at)omeninc(dot)com>
To: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Cc: John Burski <John(dot)Burski(at)911ep(dot)com>
Subject: Re: Creating Log file - run in background.
Date: 2000-12-14 23:28:54
Message-ID: 3A3957B6.CB3777FD@omeninc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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 you use
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(at)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(at)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(at)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(at)redhat(dot)com>
> # use functions, add conditional restart
>
> # Version 7.0.3 Lamar Owen <lamar(at)postgresql(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message davidb 2000-12-14 23:52:47 Re: Accessing PSQL database with MS Access via ODBC
Previous Message Sterling 2000-12-14 22:43:54 Re: Creating Log file - run in background.