| Linux scripts and tools |
The problem: You have a running backup or logging, that creates the same type of files in a given timeframe. The solution: A little "one-liner", that can be added to a existing backup-script. In my case, I decided to run it in a separate script and all folders, where I have old files, that can be deleted. The one-liner: find /backup-folder -name '*.sql.gz' -mtime +5 -exec rm {} \; If you want to run a test and verify the results first, you can run the first part without erasing files: How it works: "find" creates a list of all files, that end on ".sql.gz" in the folder "/backup-folder", that are older than 5 days. The results are passed on to the "rm" command. The curly brackets ("{}") are a placeholder for these results. Little hint for the time-preiod definition: Numeric arguments(... for the -mtime) can be specified as +n for greater than n, So, you can change values to keep old files and only delete new ones ... Hope it helps ...
Last updated by Bikerpete (admin) on Nov 11 2008 at 8:50 PM
|
|||||||||





