Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to either make ubuntu cap the trash bin at a certain size, or automatically remove items that are 30 days+ old out of the trash bin automatically? If not, does anyone know of a script anywhere that does this?

Edit: Is this even possible? It doesn't seem like the modification date of a file is even changed when it's moved to the trash.

share|improve this question

you can use find in a cron job

find /path/to/.Junk/ -type f -mtime +30 -delete >/dev/null 2>&1
share|improve this answer
    
I should add that I use this to remove junk mail from a folder. I don't know if it would work the same for the system's trash bin. – PileOfMush Nov 5 '09 at 18:04
    
The modified date doesn't seem to change when a file is moved to the trash. – ryeguy Nov 5 '09 at 18:09
    
Handling folders would be a good addition to this, though they complicate it somewhat. You don't want to remove old folders with new things inside. – blahdiblah Nov 5 '09 at 18:14
    
I don't know that this is an ideal solution, even if it does work, but just for fun... what about -atime +30? – PileOfMush Nov 5 '09 at 23:25
    
@blahdiblah, this would leave the folders in place and only handle the files in the subfolders ("-type f"). I imagine a second pass aimed at looking for empty folders would do the trick, though. – PileOfMush Nov 5 '09 at 23:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .