Having a purgatory for files that are on their way to deletion, such as the trash can in Mac OS or the recycle bin in Windows, is a great idea, for even the most careful users occasionally delete something only to find that they later need it. Unfortunately, the two aforementioned implementations, as well as those in Gnome and KDE, only allow you to empty the trash all at once. Much more useful is to have a timeout where files that are sent to the trash are automatically removed after a period of time. I finally got around to implementing this myself in Mac OS by putting the following in my crontab:
0 5 * * * /usr/bin/find /Users//.Trash -mindepth 1 -maxdepth 1 -mtime +14 -exec rm -rf {} \;
Every day at 0500 any item more than 14 days old is delete from the trash can. To install it, read the linked article above or, if you know the command line, open a terminal, type crontab -e, paste the above (substituting your username) and save the file.
Edit: In the comments, Matt mentioned Compost, a preference pane for OS X that provides the functionality I describe, but also the ability to limit the trash based upon size, and also manage the Trash on other volumes. Neat! It's $20, but definitely makes this process easier and understandable if you aren't a Unix person.


Just googled exactly this problem, thanks for the command.
But is there any reason why you didn't use -atime instead of -mtime? I mean, access time would be much more useful, wouldn't it? Modification time is not necessarily the time you moved it to trash right?
Glad this helped!
As for mtime v. atime, I actually hadn't even thought about using atime but you're right, it's much more appropriate. Looking through the find(1) man page, ctime (last metadata change time) would work, too.
This page was the first google results and really helped. Let just me add that you can run it at any time, replacing the first two numbers (0 and 5) with hours and minutes (I'm running it at midday, so my crontab entry starts with 12 0). Thanks Drew!
If you'd like a little bit prettier and more fully-featured interface, check out Compost, which is a Finder extension that implements automatic trash cleanup like this, but with more options and a GUI. I have no connection with the author, but I've been using the Compost extension for a while and love it, so I thought you might appreciate the pointer.
Thanks for the tip about Compost, it definitely brings a lot more features!
Great tip, just what I was looking for. One note tough your cron script will run at 05:00 instead of 00:05. The format for a cron job is "minutes hours ..." not "hours minutes"
Good call, J—post fixed!