The credit for this script goes to Graham Mossman
###
### housekeeping.bash
###
### Usage:
### ./housekeeping.bash
###
### Description:
### Script to run the various regular housekeeping jobs for a given database.
###
source /home/paraccel/.bashrc # this is how $housekeeping_log_dir is set
today=`date +%Y-%m-%d`
database=$1
logfile=`echo ${housekeeping_log_dir}/housekeeping_${database}_${today}.log`
echo “Starting housekeeping for $database at `date`” > $logfile 2>&1
echo “starting analyze at `date`” >>$logfile 2>&1
echo “analyze”|psql $database >> $logfile 2>&1
echo “starting vacuum at `date`” >> $logfile 2>&1
echo “vacuum”|psql $database >> $logfile 2>&1
echo “starting vacuumcat at `date`” >> $logfile 2>&1
echo “vacuumcat”|psql $database >> $logfile 2>&1
echo “starting indexcat at `date`” >> $logfile 2>&1
echo “indexcat”|psql $database >> $logfile 2>&1
echo “Ending housekeeping for $database at `date`” >> $logfile 2>&1