Computing.Net > Forums > Unix > Purge files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Purge files

Reply to Message Icon

Name: kayarsenal
Date: August 8, 2006 at 07:36:47 Pacific
OS: XP
CPU/Ram: Intel/1GB
Product: HP
Comment:

Hi All,
Please I have this script to purge files from a folder that are older than a specified date.


#!/bin/ksh

ROOTDIR=/interface/gunner
export ROOTDIR

exec 2>&1
exec 9<&0
exec 0<$ROOTDIR/Logfiles.con

while read age pattern
do
case A$age in

A\#*) ;;
A) ;;
*) path=`dirname "$pattern"`
find $path -path "$pattern" -mtime +$age -exec echo {} \; -exec rm -rf {}
\; 2>&1
;;
esac
done

exec 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



Sponsored Link
Ads by Google

Response Number 1
Name: kayarsenal
Date: August 8, 2006 at 07:52:34 Pacific
Reply:

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Purge files

Read files www.computing.net/answers/unix/read-files/7516.html

Purging K shell Script www.computing.net/answers/unix/purging-k-shell-script/7333.html

Help: how do i search a file? www.computing.net/answers/unix/help-how-do-i-search-a-file/4660.html