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
  • 79,172
  • 18
  • 156
  • 188
Bdfy
  • 21,109
  • 53
  • 126
  • 178
  • 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
ihatetoregister
  • 1,367
  • 2
  • 17
  • 35
1

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

Some programmer dude
  • 380,411
  • 33
  • 383
  • 585