Time-based file deletion on Linux

The Red Hat Linux server I use to host Workbench is filling up, largely as a result of PHP/MySQL discussion boards that I offer on several Web sites. I haven't begun deleting old messages to free space and would like to avoid that as long as possible.

To make the most efficient use of my hard disk space, I've started to run cron scripts that delete log files and other reports after a fixed time such as five days or two weeks.

Like most Linux command-line wizardry, this can be accomplished with a single shell command. Here's an example: find /report/*.twr -maxdepth 1 -mtime +14 -exec rm -f {} ;

The preceding command deletes all files that match the wildcard /report/*.twr that are 14 or more days old. It makes use of the find and rm programs.

Comments

Nut the above cmd does not find the files which starts with DOT . in the name

Add a Comment

All comments are moderated before publication. These HTML tags are permitted: <p>, <b>, <i>, <a>, and <blockquote>. This site is protected by reCAPTCHA (for which the Google Privacy Policy and Terms of Service apply).