#!/bin/sh #---------------------------------------------------------------------------- # /usr/bin/uuclean - clean up uucp spool directory # # Copyright (c) 2001-2020 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2006-11-13 jed # Last Update: $Id$ # # Source: Based on a sample uuclean shell script from # Ian Lance Taylor (Copyright (c) 1992) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # Set some variables bin_dir=/usr/bin spool_dir=/var/spool/uucp tmp_file=${spool_dir}/uuclean.$$ log_file=${spool_dir}/Log date_stamp=`date +"%F %H:%M:%S.00 $$"` # write log entry echo "uuclean - - (${date_stamp}) cleaning up uucp spool directory ..." >> ${log_file} # warn about all mail over two days old ${bin_dir}/uustat -c rmail -o 48 -N -Q -W"Unable to deliver; will try up to one week." # return all mail over a week old ${bin_dir}/uustat -c rmail -o 168 -K -M -N -Q -W"Could not be delivered for over one week." # throw away other requests over a week old ${bin_dir}/uustat -o 168 -K -M -N -Q -W"Over one week old." # warn about any non rmail executions over three days old ${bin_dir}/uustat -o 72 -C rmail -M -N -Q -W"Unable to execute for three days." if [ -d ${spool_dir} ] then # delete temporary file, if exists rm -f ${tmp_file} # find any old spool files find ${spool_dir} -ctime +8 -name '[CDX].*' -print > ${tmp_file} # find any old temporary files find ${spool_dir} -atime +1 -ctime +1 -name 'TM.*' -print >> ${tmp_file} # find any old preserved files if [ -d ${spool_dir}/.Preserve ] then find ${spool_dir}/.Preserve -atime +14 -ctime +14 -print >> ${tmp_file} fi # find any old failed execution files if [ -d ${spool_dir}/.Failed ] then find ${spool_dir}/.Failed -atime +14 -ctime +14 -print >> ${tmp_file} fi if [ -f ${tmp_file} ] then # delete overdue files and directories for FDNAME in `cat ${tmp_file} | sort -r` do if [ -d ${FDNAME} ] then # delete directory echo "uuclean - - (${date_stamp}) deleting directory '${FDNAME}' ..." >> ${log_file} rmdir --ignore-fail-on-non-empty ${FDNAME} else # delete file echo "uuclean - - (${date_stamp}) deleting file '${FDNAME}' ..." >> ${log_file} rm -f -r ${FDNAME} fi done # delete temporary file, if exists rm -f ${tmp_file} fi fi # write log entry echo "uuclean - - (${date_stamp}) done." >> ${log_file} #---------------------------------------------------------------------------- # end #----------------------------------------------------------------------------