Delete files older than x minutes (Linux)
26 Oct
Up until recently, I’d never needed to delete files automatically that were less than a day old. There is a useful switch you can pass to find that lets you return files that haven’t been changed in x minutes, and that can be used for temporary file cleanups or whatever.
Here it is:
find /tmp/foo/ -type f -cmin +180 | xargs /bin/rm -rf
That will return any files inside /tmp/foo/ that haven’t been changed in at least 3 hours.

