#!/bin/sh
####################################################
#
# Shell script: clean-rptdir
#
# 1999, Michael Doran, doran@uta.edu
# University of Texas at Arlington Libraries
#
# Moves no-longer needed files from the voyager
# report directory to the /tmp directory for
# deletion at next reboot.
#
# runs from root crontab
#
####################################################
# Variables
rpt_dir=/m1/voyager/xxxdb/rpt
storage=/tmp
sess_file=/tmp/clean.$$
ntfy_rcp=operator
# Function to add comments to session file
add ()
{
/usr/bin/echo "$1" >> ${sess_file}
}
add "$0\n`date`\n"
add " The following files have been removed from ${rpt_dir} \n \
and placed in ${storage}. They will be deleted the next time that\n \
`uname -n` is booted.\n"
# Find the report and notice files that have not been downloaded
# (i.e. don't end in "inp") and that are older than 60 days.
# Move them to the tmp directory and add list to session file.
# Also move Pmarcexport log and output files older than 60 days.
for file in acqnotes acqrprts crcnotes crcrprts log.exp marc.exp
do
/usr/bin/find ${rpt_dir} \( -name ${file}*[0-9] -a -mtime +60 \) \
-print -exec mv {} ${storage} \; >> ${sess_file}
done
# Mail session file
/usr/bin/mailx -s "clean-rptdir" ${ntfy_rcp} < ${sess_file}
exit 0
|