Monday, 19 May 2014

Find....

  • Find and compress files older then X days
find /path/to/files/ -type file -mtime 1 -exec gzip {} \;

1 means 24 hours old
-1 means less than 24 hours old
+0 means more than 24 hours old
+1 means more than 48 hours old

  • Find and compress files older then 5 days and exclude files already compressed (ext .gz)

find /path/to/files/ \( ! -name *.gz \) -type file -mtime +5 -exec gzip {} \;

No comments:

Post a Comment