Neat Linux tip

Lots of times I have a need to make a backup of a file or such that I end up forgetting about and it sits around taking up disk space. Sometimes in annoyance of this, I have simply skipped making the backup, and have been burned by it. Finally I came up with this alternative:

  1. Make a directory on your desktop called DeleteIn2Weeks. In my case, the full path was /home/guytonw/Desktop/DeleteIn2Weeks
  2. Create the following cron entries:
    0 1 * * * find /home/guytonw/Desktop/DeleteIn2Weeks -mtime +14 -type f -exec echo Deleting {} \;
    1 1 * * * find /home/guytonw/Desktop/DeleteIn2Weeks -mtime +14 -type f -exec rm {} \;

This is nice because any files put in there will automatically be swept away after a sufficient amount of time. (Hopefully I won’t need the backup after 2 weeks’ time!)