top | item 36118281

(no title)

alch- | 2 years ago

I'm very happy with my system: I have ~/tmp/ with subdirs `hour`, `day`, `week`, `month`, `6months`, `2years`. Files in each of these get removed by a cronjob x time after they were created/modified (i.e. after an hour; a day; etc).

  */10 * * * * /usr/bin/find ~/tmp/hour/ -mindepth 1 -mmin +60 -cmin +60 -delete
  0    * * * * /usr/bin/find ~/tmp/day/ -mindepth 1 -mmin +1440 -cmin +1440 -delete
  # etc
Files in ~/Downloads/ are deleted in the same way, after 2 hours. If I download something that I want to keep "forever", I move it to where it belongs. Anything that is not "forever" goes into one of the ~/tmp/ subdirs (with a useful filename so I can trivially find it when I need it). You get into the habit of moving things out of ~/Downloads/ very quickly, and it's not very painful: downloaded things can almost always be re-downloaded if you forgot to move them.

I used to have another (crude) cronjob to warn me before deleting files:

  0 21 * * * (/usr/bin/find /Users/me/tmp/week/ -mindepth 1 -mtime +5 -ctime +5; /usr/bin/find /Users/me/tmp/month/ -mindepth 1 -mtime +28 -ctime +28; /usr/bin/find /Users/me/tmp/6months/ -mindepth 1 -mtime +183 -ctime +183) | /usr/bin/sed 's/^.Users.me.tmp.//g' | /usr/bin/mail -E -s "will delete some ~/tmp files soon" me@domain
... but I found it unnecessary. In practice, I just take some margin in deciding where to put things. If I think I'll need it for max a week, I'll put it in tmp/month to be on the safe side, etc. And worst case, I can just retrieve it from my backups.

I can't recommend a system like this enough. It feels like "inbox zero" for your filesystem; very liberating.

discuss

order

No comments yet.