Hi!

I haven't found anything in terms of startup- and check-scripts for
pg_autovacuum yet; usually I like to have some sort of mechanism to
check if some daemon is running and restart it if it isn't.

Of course this sort of script shouldn't be too much of a bother for more
experienced users; however you might actually find this small
checkup-script more or less useful - just save it in /opt/pgsql/bin/ as
autovachk, chmod +x and follow the included instructions for adding it
to your crontab.

Regards

        Markus

#!/bin/sh
#
# This is a script suitable for use in a crontab.  It checks to make
sure
# your pg_autovacuum daemon is running.
#
# To check for the daemon every 5 minutes, put the following line in
your
# crontab:     
#    2,7,12,17,22,27,32,37,42,47,52,57 * * * *
#      /opt/pgsql/bin/autovachk >/dev/null 2>&1

# change this to the directory you run the daemon from: 
dir="/opt/pgsql/bin"

# change this to the complete commandline you usually start the daemon
with
daemoninvoc="pg_autovacuum -D -U postgres -L /var/log/pgautovac.log"

# I wouldn't touch this if I were you.
daemonpid=`eval ps ax | sed -n '/[p]g_autovacuum/p' | awk '{ print $1
}'`
########## you probably don't need to change anything below here
##########

cd $dir
if `kill -CHLD $daemonpid >/dev/null 2>&1`; then  
  # it's still going, so back out quietly  
  exit 0              
fi  
echo ""
echo "Couldn't find the pg_autovacuum daemon running.  Reloading it..."
echo ""
./$daemoninvoc
sleep 3

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to