#!/bin/sh HOME=xxx CONFIGFILE=HouseKeeping.config LOGFILE=HouseKeepingLog.txt date | tee -a $LOGFILE | cat echo "**********************Script start**********************" | tee -a $LOGFILE | cat cd $HOME count=0 sum=0 while read conLine do count=`expr $count + 1` path=`echo $conLine | awk '{print $1}'` type=`echo $conLine | awk '{print $2}'` time=`echo $conLine | awk '{print $3}'` echo "No."$count" Directory: "$path | tee -a $LOGFILE | cat if [ -e $path ]; then if [ $type -eq 1 ]; then find $path ! -path $path -type d -mtime +$time | while read LINE do sum=`expr $sum + 1` echo "Remove Directory "$LINE | tee -a $LOGFILE | cat rm -rf "$LINE" done elif [ $type -eq 2 ]; then find $path -type f -mtime +$time | while read LINE do sum=`expr $sum + 1` echo "Remove File "$LINE | tee -a $LOGFILE | cat rm -rf "$LINE" done else echo "Illegal Parameter." | tee -a $LOGFILE | cat fi else echo "The specified directory doesn't exist." | tee -a $LOGFILE | cat fi done < $CONFIGFILE echo $count" directory have been processed and "$sum" File/Folder have been deleted." | tee -a $LOGFILE | cat echo "**********************Script end**********************" | tee -a $LOGFILE | cat date | tee -a $LOGFILE | cat