Re: Is there is shutdown utility for postgresql? - Mailing list pgsql-general

From Paul Tomblin
Subject Re: Is there is shutdown utility for postgresql?
Date
Msg-id 20020115185154.A9215@allhats.xcski.com
Whole thread Raw
In response to Is there is shutdown utility for postgresql?  ("Jeff Lu" <jklcom@mindspring.com>)
List pgsql-general
Quoting Jeff Lu (jklcom@mindspring.com):
>
> Is there another to shutdown the database other than "kill" or ctrl-C?

Probably a simple "pg_ctl stop" would do it most of the time, but this is
what it does on RedHat 7.2.

stop(){
    # Check for postmaster already running... exit if this happens
    pid=`pidof -s postmaster`
    if [ "$pid" == "" ]; then
        rm -f /var/run/postmaster.pid
        rm -f /var/lock/subsys/postgresql
        exit 0;
    fi
    echo -n $"Stopping postgresql service: "
    # 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
    su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl stop -D $PGDATA -s -m fast" > /dev/null 2>&1
        ret=$? # This will always be 0, as the return code doesn't propagate... Fix that some day.
        if [ $ret -eq 0 ]; then
        echo_success
        else
            echo_failure
        fi
    echo
    rm -f /var/run/postmaster.pid
    rm -f /var/lock/subsys/postgresql
}

--
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
Real Time, adj.:
    Here and now, as opposed to fake time, which only occurs there
and then.

pgsql-general by date:

Previous
From: "Jeffrey W. Baker"
Date:
Subject: Re: Is there is shutdown utility for postgresql?
Next
From: "Artigas, Ricardo Y."
Date:
Subject: Re: Is there is shutdown utility for postgresql?