By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,809 Members | 1,999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,809 IT Pros & Developers. It's quick & easy.

Cron-job for checking up on pg_autovacuum

P: n/a
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

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Markus Wollny wrote:
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.


Agreed, this needs to be improved. In the long term, pg_autovacuum
should be started and stopped with the postmaster. However, as it is a
contrib module right now, it won't happen.

I know I heard from at least one person who said they were running it
from there inittab with respawn, which seems like overkill.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #2

P: n/a
On Tue, 2003-11-25 at 02:13, Markus Wollny wrote:
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.


The Debian package of 7.4 starts pg_autovacuum in the rc script if it is
so configured.

--
Oliver Elphick Ol************@lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Who shall ascend into the hill of the LORD? or who
shall stand in his holy place? He that hath clean
hands, and a pure heart..." Psalms 24:3,4
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #3

P: n/a
When grilled further on (Tue, 25 Nov 2003 11:19:32 -0500),
"Matthew T. O'Connor" <ma*****@zeut.net> confessed:
I know I heard from at least one person who said they were running it
from there inittab with respawn, which seems like overkill.


Nah, it works great (it was me). I just had an unclean shutdown/reboot, and
pg_autovacuum couldn't connect on start because PGSQL was coming up. inittab
took note of the quick respawning and put a 5 minute delay in there. And I got
to ignore it.

Also works great when PGSQL is down for any reason. You don't have to worry
about stopping/starting pg_autovacuum...

Overkill is a good thing! It keeps stuff working ;-)

Cheers,
Rob

my /etc/inittab line (Mandrake 9.1 system)

vac:235:respawn:su - postgres -c "/usr/local/pgsql/bin/pg_autovacuum -d 0"

--
22:06:18 up 2 days, 4:12, 1 user, load average: 2.11, 2.15, 2.17

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iEYEARECAAYFAj/JfFwACgkQLQ/DKuwDYzmKyQCeJARBODej/Zi2v98W1wWcTJ6L
2YYAnj/QTBdMoL5p5IVuXNvfCbWog1vC
=PGEq
-----END PGP SIGNATURE-----

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.