Cron-job for checking up on pg_autovacuum - Mailing list pgsql-general

From Markus Wollny
Subject Cron-job for checking up on pg_autovacuum
Date
Msg-id 2266D0630E43BB4290742247C891057502B9D368@dozer.computec.de
Whole thread Raw
Responses Re: Cron-job for checking up on pg_autovacuum
Re: Cron-job for checking up on pg_autovacuum
List pgsql-general
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

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Humor me: Postgresql vs. MySql (esp. licensing)
Next
From: Bruce Momjian
Date:
Subject: Re: array iteration?