LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell script/cmd to remove old folders in a directory? (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-cmd-to-remove-old-folders-in-a-directory-715308/)

exxoid 03-29-2009 01:25 PM

Shell script/cmd to remove old folders in a directory?
 
Hello,

Hoping someone could help me here, we have a back-up that takes snapshots of one of our DB servers and copies over the files to another server's directory for back-up.

This directory can grow rapidly with many back-ups as they are taken on a 5-minute timer.

I was looking for a shell script/cmd line to remove any folders in a specific directory that is older than 10 days.

Anyone able to help?

Thank you.

pwc101 03-29-2009 01:38 PM

Code:

find /dir/to/backups -mtime +10 -exec echo rm {} +
I put an echo command in there so you don't accidentally nuke all your backups on the first go. Make sure the output is as you expect, then remove the echo and let rm do its thing.


All times are GMT -5. The time now is 02:13 AM.