473,414 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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

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

Nov 12 '05 #1
3 2702
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Doug | last post by:
I have Windows XP professional. Is there ANYTHING reliable on Windows that is like cron on UNIX that will allow you run something at regular intervals, for example, like every 10 minutes? I...
6
by: sherryonline | last post by:
i have a page and i need that page to be called every day at 12:00 that page is going to connect to the database fetch some emails and will start mailing them how i am goning to do this.
3
by: the.natalie | last post by:
Hi. I am a newbie to mysql, cron, and shell scripting, so please bear with me. I have a script that is used for updating an image directory based on contents in a database. The script does the...
6
by: giangiammy | last post by:
I don't know if this is possible, but I need to accomplish an action at a given hour (what cron does): is it possible to do something like this having a web hosting service with php support? ...
2
by: erikcw | last post by:
Hi all, When trying to run this python script from cron, I get the following error: Traceback (most recent call last): File "/home/lybp/public_html/wa/wa.py", line 14, in ? import MySQLdb...
4
by: pushpen | last post by:
I'm trying to run the following php code along with gd library as a cron job ,but cron is not generating any output. When I run this code from my browser I get an image correctly. Somebody please...
4
by: Phil | last post by:
I have a php script that queries some Oracle DB and outputs a single line of plain text with <brat the end for each query. This is Apache2, php4.4.8 and Oracle Instant Client 10.1.0.5 all on CentOS...
4
by: Stephen Cattaneo | last post by:
Hello all, I am attempting to execute an automated test (written in Python) via cron. I have to check the HOSTNAME variable as part of the test, oddly under cron the HOSTNAME environment...
0
by: Cameron Simpson | last post by:
On 17Aug2008 21:25, John Nagle <nagle@animats.comwrote: Because $HOSTNAME is a bash specific variable, set by bash but NOT EXPORTED! Like $0 and a bunch of other "private" variables, subprocesses...
1
by: Karthik Gurusamy | last post by:
Hi, I'm working on a cron like functionality for my application. The outer loops runs continuously waking every x seconds (say x=180, 300, ..). It needs to know what events in cron has expired...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.