#!/bin/sh # Program: truncate_log # Purpose: To the log file for one or more databases # Author: Adam Backman # Date: 06/11/98 # SCRIPTS=${SCRIPTS-/u3/users/adamb/scripts} HOSTNAME=`hostname` LOGLINES=${2-2000} export SCRIPTS HOSTNAME LOGLINES case $1 in all|ALL|All) for i in `grep $HOSTNAME $SCRIPTS/live/db.registry | cut -s -f 1 -d "|"` do if [ $i != "#DB" ] then . $SCRIPTS/live/read_registry $i if [ $? = "0" ] then tail -$LOGLINES $DB_DIR/$DB.lg > $SCRIPTS/tmp/$DB.lg chmod 666 $SCRIPTS/tmp/$DB.lg umask 666 mv $SCRIPTS/tmp/$DB.lg $DB_DIR/$DB.lg fi fi done ;; *) . $SCRIPTS/live/read_registry $1 case $? in 2) echo "Database $1 is not in database registry" exit 1 ;; 3) echo "Database $1 is on $HOST not on this host" exit 1 ;; esac tail -$LOGLINES $DB_DIR/$DB.lg > $SCRIPTS/tmp/$DB.lg chmod 666 $SCRIPTS/tmp/$DB.lg umask 666 mv $SCRIPTS/tmp/$DB.lg $DB_DIR/$DB.lg ;; esac