Thread: Cron-job for checking up on pg_autovacuum
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
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.
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 Oliver.Elphick@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
When grilled further on (Tue, 25 Nov 2003 11:19:32 -0500), "Matthew T. O'Connor" <matthew@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