Delete files older than X number of days in Linux

Say you backup your database daily and you need to delete the old backup files.
You can issue the command bellow which will erase any files within the specified directory that are older than 7 days.

1
$ find /your/target/directory* -mtime +7 -exec rm {} \;
This entry was posted in Bash, Linux, Operating System. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


three × 6 =