#!/usr/local/bin/bash . sql.functions # This script cleans out old tables in the database if they exceed # G_EXPIRE_TABLES seconds of age. It also cleans out temp directories # created by the archive.cgi script. # NOW=`date '+%s'` TABLES=`f_ltable_list` for T in $TABLES ; do T_DATE=`date -j -f 'pkt_%Y_%m_%d_%H_%M_%S' "$T" '+%s'` AGE=$(($NOW - $T_DATE)) if [ $AGE -gt $G_EXPIRE_TABLES ] ; then echo "Deleting $T ..." echo "drop table $T" | $V_MYSQL fi done # Now clean out tmp.xxx directories left behind, but only if they've been # sitting there really long. cd $G_HTDOCS TMP_DIRS=`find . -type d -name "tmp.*"` for I in $TMP_DIRS ; do eval `stat -s $I` AGE=$(($NOW - $st_ctime)) if [ $AGE -gt 600 ] ; then echo "Removing $I ..." rm -fr $I fi done