1

How do I recursively delete files in directory that were modified more than 6 hours ago?

This example work for 1 day:

find /data2/input -type f -mtime +1 -delete -print
Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
Bdfy
  • 23,141
  • 55
  • 131
  • 179
  • See: [-mtime FIles older than 1 hour](http://stackoverflow.com/questions/543946/mtime-files-older-than-1-hour) – slhck Nov 17 '11 at 11:43

2 Answers2

3

Use -mmin instead of mtime. It will allow you to specify the number of minutes since the files was last modified. So for files older than 6 hours:

find /data2/input -type f -mmin +360 -delete -print
norq
  • 1,404
  • 2
  • 18
  • 35
1

Check the flags -cmin or -mmin in the manual page.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621