0

Is there a way I could delete certain folders after x amount of days of inactivity? I was thinking of using cron but that wouldn't take the inactivity part into consideration. Is there any Debian software out there that would do it? Or is there a Linux command that I am not aware of?

I've tried researching for something out there that could, but have had no luck.

I'm running Debian Wheezy at the moment.

Anthon
  • 79,293
  • What do mean with 'x amount days of inactivity'? That the computer was off? That nobody touched the keyboard or mouse? That no files were added, deleted or modified in the tree beneath those directories? That you stayed in bed all day? – Anthon Apr 13 '15 at 20:38
  • by inactivity, i mean that a certain directory or file was not modified in any way in x amount of days. – Muji Sayed Apr 13 '15 at 20:41

2 Answers2

2

Take a look at tmpreaper: it allows you to clean up files within certain directories based on their inactivity. It provides a large number of options to control what it cleans up (or leaves untouched) in detail.

Stephen Kitt
  • 434,908
0

Sounds like a task for 'find': find /tmp -mtime +30 -delete (with the side effect that deleting a file from within a directory changes its mtime, so the counter resets on that directory)

Johnny
  • 2,140