Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All,
Please I have this script to purge files from a folder that are older than a specified date.
#!/bin/kshROOTDIR=/interface/gunner
export ROOTDIRexec 2>&1
exec 9<&0
exec 0<$ROOTDIR/Logfiles.conwhile read age pattern
do
case A$age inA\#*) ;;
A) ;;
*) path=`dirname "$pattern"`
find $path -path "$pattern" -mtime +$age -exec echo {} \; -exec rm -rf {}
\; 2>&1
;;
esac
doneexec 0<&9
exec 9<&-
In the logfiles.con should be something like this:#Days Pattern
#to keep
7 /interface/DU1.*
7 /interface/DU2.*
7 /interface/DU3.*
7 /interface/DU4.*Could someone please interpret this to me?
Thanks
Kayzone

Hi,
Still me,if you have a different solution,please send it to me, I need to purge all files older than say 7days in a folder that contains subfolders and files. The script looks into the root folders, check each and every subfolder and files, and checks the last modified date(mtime +$n),based on that, it removes(purges) the files(rm -rf).Thanks
Kayzone

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |