Sunday, September 29, 2024

Compress files in Linux for certain date range

Compress log files modified between August 1, 2024, and September 21, 2024, in the /tigergraph/logs/gsql directory into a ZIP archive named gsqlfilesm1.zip


$ zip -r /tmp/gsqlfilesm1.zip $(find /tigergraph/logs/gsql -type f -newermt 2024-08-01 ! -newermt 2024-09-21)


  • find /tigergraph/logs/gsql -type f -newermt 2024-08-01 ! -newermt 2024-09-21: Finds all files in /tigergraph/logs/gsql that were modified between August 1, 2024, and September 21, 2024.

  • zip -r /tmp/gsqlfilesm1.zip: Recursively adds these files to a ZIP archive located at /tmp/gsqlfilesm1.zip.
In Tigergraph DB run on all nodes by running "grun_p" command.

$ grun_p all "zip -r /tmp/gsqlfilesm1.zip $(find /tigergraph/logs/gsql -type f -newermt 2024-08-01 ! -newermt 2024-09-21)"


***

No comments:

Post a Comment