Header RSS Feed
 
» IT tipps and howto's

How To: Delete files older than x days

This is actually VERY simple - if you know how to do it. In combination with the command find, you are able to look for files and folders with a certain age, followed by a command.

The following example deletes all files within the actual directory which are older than 7 days (now +7).
Important: Don't forget {} \; at the end of the command!

find . -name '*' -mtime +7 -exec rm -f {} \;

Last Update: 23.05.2008


Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6979 Days
until Death of Computers
Why?