Delete files older than X number of days in Linux

Written by

in

, ,

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.


$ find /your/target/directory* -mtime +7 -exec rm {} \;

Comments

Leave a Reply

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