Thursday, 22 December 2011

How to delete older files in UNIX



export PATH=${PATH}:/usr/contrib/bin
FILESPATH="/location from where you have to delete files"
cd $FILESPATH
print "Following files will be deleted"
find . -name '*.log' -print -mtime +30 -exec ls -l {} \+
find . -name '*.LOG' -print -mtime +30 -exec ls -l {} \+
find . -name '*.tracesql' -print -mtime +30 -exec ls -l {} \+
print "Files older than 30 days deleted"
rm -rf *.log -print -mtime +30 -exec ls -l {} \+
rm -rf *.LOG -print -mtime +30 -exec ls -l {} \+
rm -rf *.tracesql -print  -mtime +30 -exec ls -l {} \+

0 comments:

Post a Comment