Nicolas Huillard wrote: >Do you have a URL to this script, or can you send it back via mail, if you h >ave/use it ? (I use RedHat, and there is no script like that in it). >-----Message d'origine----- >De: Oleg Broytmann [SMTP:[EMAIL PROTECTED]] >Date: jeudi 16 décembre 1999 15:45 >À: Nicolas Huillard >Cc: '[EMAIL PROTECTED]' >Objet: RE: [ADMIN] Vacuum script > > Debian GNU/Linux system distrubuted with excelent script of this sort - >it asks Postgres, get a list of DBs and vacuum them all in a loop. Here is the script (in the attachment). It uses several commands whose detailed operation may be different on systems other than Debian GNU/Linux. Since I wrote it for Debian, I wasn't concerned for wider portability. If anyone solves any portability problems, please mail the solutions to me and I will submit the result for inclusion in 7.0. Oliver
#! /bin/sh # # Script for automatic maintenance of Debian PostgreSQL, to be run by cron, # with the owner being the postgres superuser # # If called with the user and password options, make sure the crontab file # is sufficiently protected (600 permissions). syntax() { echo Syntax: $0 [-v] [-a] [-u user -p password] exit 1 } verbose= analyse= while getopts avu:p: arg do case $arg in a) analyse=analyze ;; v) verbose=verbose ;; u) user=$OPTARG ;; p) password=$OPTARG ;; *) syntax;; esac done if [ -n "$user" -a -z "$password" ] then syntax fi if [ -z "$user" -a -n "$password" ] then syntax fi set -a . /etc/postgresql/postgresql.env # This Debian-specific file sets any necessary # environment variables if [ -z "$user" ] then dblist=$(psql -t -c "select datname from pg_database order by datname" -d template1) else dblist=$(psql -u -t -c "select datname from pg_database order by datname" -d template1 <<EOI | tail +3 $user $password EOI ) fi for database in $dblist do if [ -n "$verbose" ] then echo Vacuuming $database fi if [ -z "$user" ] then /usr/bin/psql -c "vacuum ${verbose} ${analyse}" -q -S -d $database else /usr/bin/psql -u -c "vacuum ${verbose} ${analyse}" -q -S -d $database <<EOI $user $password EOI fi done
Vote against SPAM: http://www.politik-digital.de/spam/ ======================================== Oliver Elphick [EMAIL PROTECTED] Isle of Wight http://www.lfix.co.uk/oliver PGP key from public servers; key ID 32B8FAA1 ======================================== "Let another man praise thee, and not thine own mouth; a stranger, and not thine own lips." Proverbs 27:2