Skip to content

find by date and tar them

find by date and tar them published on No Comments on find by date and tar them

If you have a big log folder and you want to tar the newest log files in to one tar.gz file, then you can use the following:

find /opt/tomcat/logs/ -type f -newermt 2013-06-09 | tar cvzf testfind.tar.gz -T - --null

I do not know the meaning of -T - --null, but it works.

 

Perhaps your find version is to old for the newermt statement. With find version 4.2.27 it did not work. Then you could use -mtime, for modification time.
mtime is the number * 24 h, do find all files older newer then one day, you can use:

find /opt/tomcat/logs/ -type f -mtime 1

+1 would mean older than one day

Leave a Reply