#!/bin/bash
#
# This Script removes all old files from particular directories
#
set -x
remFiles(){
path=`echo $1` # This is inefficient but We dont expect too many files
days=$2
dirs=$3
for dir in $path;do
if [ -z "$dirs" ];then
find "$dir" -mtime +$days -type f -exec rm -vf {} \;
else
find "$dir" -mtime +$days -type d -exec rm -vfr {} \;
fi
done
}
remFiles "/net/serverbackup/backup/*" "2"
No comments:
Post a Comment