I finally added this script to /etc/cron.daily (I use RedHat 5.1, and this directory
contains scripts that are ran by root each day at 4:02) :
#!/bin/sh
su postgres -c 'psql -t -c "select datname from pg_database order by datname;"
template1 | xargs -n 1 psql -q -c "vacuum analyze;"'
I think it's the best way to go under RedHat. All the scripts in /etc/cron.daily are
run one by one, this way there is no transient overload on the machine, if some heavy
scripts are added (and this one may be heavy).
Thanks for every answer.
Nicolas Huillard
-----Message d'origine-----
De: Lamar Owen [SMTP:[EMAIL PROTECTED]]
Date: jeudi 16 décembre 1999 17:44
À: Nicolas Huillard
Cc: '[EMAIL PROTECTED]'
Objet: Re: [ADMIN] Vacuum script
Nicolas Huillard wrote:
>
> Thanks for this very simple and beautiful line !
> You could simplify it by only having :
> 02 0 * * * echo "vacuum verbose;" | psql faq
>
> Frankly, I'd prefer a script that automatically adapt to any added database in the
>whole system : as an administrator, I don't want to edit my/postgres crontab each
>time a new DB is added to Postgres...
I use the following crontab entry here (one line):
03 0 * * * psql -t -c "select datname from pg_database" template1 |
xargs -n 1 psql -q -c "vacuum analyze"
This pulls out all database names in simplified format (no header and no
count), pipes it to the command splitter xargs, which executes a quite
mode psql VACUUM for each database output by the first psql. Syntax to
xargs is tricky here -- it is in fact nonobvious that the simplest
syntax is the correct syntax. If you want some output e-mailed to you,
strip out the -q, and add verbose to the vacuum ("vacuum verbose
analyze").
--
Lamar Owen
WGCR Internet Radio
1 Peter 4:11
************
************