Author: nunofsantos
Date: 2009-02-25 14:04:18 -0500 (Wed, 25 Feb 2009)
New Revision: 3136
Modified:
mgmt/trunk/mint/bin/mint-vacuumdb
Log:
check for a running postgresql before attempting to vacuum
Modified: mgmt/trunk/mint/bin/mint-vacuumdb
===================================================================
--- mgmt/trunk/mint/bin/mint-vacuumdb 2009-02-25 18:02:19 UTC (rev 3135)
+++ mgmt/trunk/mint/bin/mint-vacuumdb 2009-02-25 19:04:18 UTC (rev 3136)
@@ -2,14 +2,24 @@
TABLES="slot slot_stats job job_stats sysimage sysimage_stats"
-if [ "$1" == "full" ]; then
+function check_pid() {
+ PID=`pidof postmasterr`
+ if [[ $? == 1 ]]; then
+ echo "Postgresql is not running, can't perform vacuum"
+ exit
+ fi
+}
+
+if [ "$1" == "all" ]; then
+ check_pid
/usr/bin/vacuumdb --dbname=cumin --analyze --echo --verbose --host=localhost
--username=cumin
elif [ "$1" == "tables" ]; then
+ check_pid
for t in $TABLES ; do
/usr/bin/vacuumdb --dbname=cumin --table="$t" --analyze --echo --verbose
--host=localhost --username=cumin;
done
else
- echo "Usage: mint-vacuumdb [full | tables]"
- echo " full = performs a database-wide vacuum/analyze"
+ echo "Usage: mint-vacuumdb [all | tables]"
+ echo " all = performs a database-wide vacuum/analyze on all tables"
echo " tables = performs a vacuum/analyze on a few pre-selected tables"
fi