0

I would like to backup all files older than 90 days and greater plus gzip them. I could execute:

find /path/to/files -type f -mtime 90 -exec gzip "{}" \;

Problem with this command is it includes files 90 days old and not older ones. So it will gzip June's files but not May's. Thanks!

nizbit
  • 13
  • 3

3 Answers3

2

for exactly 90 it should be -mtim +89

FargolK
  • 1,667
2

From man find

+n     for greater than n,
-n     for less than n,
 n      for exactly n.

-mtime n
    File's data was last modified n*24 hours ago.  See the comments for -atime to understand how rounding affects the interpretation of file modification times.

So the correct line to backup files modified more than 90 days ago, will be

$ find /path/to/files -type f -mtime +90 -exec gzip {} +
iruvar
  • 16,725
tachomi
  • 7,592
1

-mtime +90 should do the trick.