find </toplevel_directory> -type f -mtime +30 -exec rm {} \;
This traverses through your directory structure and deletes all files over 30 days old. To get an idea as to what it is going to delete, it may be best to replace the -exec rm {} \; with a simple -print command first, as it's all too easy to set this off in the wrong place and delete the wrong files! HTH.
I'm just a rookie here, but don't you want a "-f" after the rm, so that it won't try to prompt you for each deletion?
As a side note, why not do this as a crontab entry, rather than a script? I run a crontab entry on my machines that runs every night at midnight and deletes any tiff files in a certain directory that are more than one day old. It looks like this:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.