Latest pg_autovacuum script

From: Theo Galanakis <Theo(dot)Galanakis(at)lonelyplanet(dot)com(dot)au>
To: pgsql-admin(at)postgresql(dot)org
Subject: Latest pg_autovacuum script
Date: 2005-04-15 02:14:20
Message-ID: D1444817B78AB546BF2896C2B70E7F04372012@ganesh.au.lpint.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


Hi,
I have updated the pg_autovacuum script with some bug fixes and
changes. Hope you find this useful.

-- This goes where all the other init scripts are located.
-- Can be placed at the top of /etc/rc.d/init.d/postgresql script or in the
/etc/sysconfig/pgsql/{name of script} e.g. postgresql, pg1, pg2
# Initialize pg_autovacuum defaults. Theo Galanakis 11/04/2005
PGAUTO_LOGFILE=/var/log/pg_autovacuum.{$PGPORT}.log
PGAUTO_SLEEP=600

--Include at the top of /etc/rc.d/init.d/postgresql
# pg_autovaccum Include script file. Theo Galanakis 11/04/2005
. $INITD/autovacuum

--Update case statement in postgresql script
case "$1" in
start)
start
startautovacuum
;;
stop)
stop
stopautovacuum
;;
status)
status postmaster
statusautovacuum
;;
restart)
restart
restartautovacuum
;;

--Create a new file /etc/rc.d/init.d/autovacuum with this content.
startautovacuum() {
# Start pg_autovacuum. Theo Galanakis 11/05/2005
# Note : ensure $PGENGINE is being used in script otherwise hardcode
to /usr/bin/
if [ -f /var/run/pg_autovacuum.${PGPORT}.pid ]
then
echo $"pg_autovacuum already running."
else
PAUTO_START=$"Starting pg_autovacuum service: "
echo -n "$PAUTO_START"
pg_autovacuum -D -s ${PGAUTO_SLEEP} -p ${PGPORT} -U postgres
-L ${PGAUTO_LOGFILE}
sleep 1
pg_autovacuum_pid=`pidof -s $PGENGINE/pg_autovacuum`
if [ $pg_autovacuum_pid ]
then
success "$PAUTO_START"
echo $pg_autovacuum_pid >
/var/run/pg_autovacuum.${PGPORT}.pid
echo
else
failure "$PAUTO_START"
echo
fi
fi
}

stopautovacuum () {
# Stop pg_autovaccum. Theo Galanakis 11/04/2005
if [ -f /var/run/pg_autovacuum.${PGPORT}.pid ]
then
pg_autovacuum_pid=`head -n 1
/var/run/pg_autovacuum.${PGPORT}.pid`
ret=`ps --no-heading ${pg_autovacuum_pid}`
if [ -z "$ret" ]
then
echo $"pg_autovacuum: pid [${pg_autovacuum_pid}]
stored in /var/run/pg_autovacuum.${PGPORT}.pid does not exist."
else
echo -n $"Stopping pg_autovacuum service: "

kill -TERM $pg_autovacuum_pid
ret=`ps --no-heading ${pg_autovacuum_pid}`
if [ -z "$ret" ]
then
echo_success
else
echo_failure
fi
echo
rm -f /var/run/pg_autovacuum.${PGPORT}.pid
fi
else
echo $"pg_autovacuum is not running."
fi
}

statusautovacuum() {
# Status pg_autovacuum. Theo Galanakis 11/04/2005
if [ -f /var/run/pg_autovacuum.${PGPORT}.pid ]
then
pg_autovacuum_pid=`head -n 1
/var/run/pg_autovacuum.${PGPORT}.pid`
ret=`ps --no-heading ${pg_autovacuum_pid}`
if [ -z "$ret" ]
then
echo $"pg_autovacuum not running..."
else
echo $"pg_autovacuum (pid ${pg_autovacuum_pid}) is
running..."
fi
else
status pg_autovacuum
fi
}

restartautovacuum() {
stopautovacuum
startautovacuum
}

______________________________________________________________________
This email, including attachments, is intended only for the addressee
and may be confidential, privileged and subject to copyright. If you
have received this email in error, please advise the sender and delete
it. If you are not the intended recipient of this email, you must not
use, copy or disclose its content to anyone. You must not copy or
communicate to others content that is confidential or subject to
copyright, unless you have the consent of the content owner.

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Bob Smith 2005-04-15 07:31:28 Referential constraints in version 8
Previous Message gayatri ganpaa 2005-04-14 21:18:31 Support for raster Data