Monday, June 13, 2011

Unix - Find/Delete n-days old files

Command to Find/Delete n-days old files… Especially useful for cleaning up logs. (if you are not using rolling logs for some reason)

Find n-days old files:
        >> find . -type f -mtime +5

Delete n-days old files:
        >> find . -type f -mtime +5 | xargs rm

No comments:

Post a Comment