Compressing log files

By David
/
First published 8th December 2024

I have a status shell script that runs every minute (see Sleeping until top of the minute). This shell script generates a daily log file bu adding a few lines of text to a file. Every few months I want to compress and zip these files since they compress well (I do have plenty of disk space but it seems wasteful to leave historical log files uncompressed. To do this I issue the following commands:

  • tar --remove-files -cf adsl.2024.oct.tar adsl-202410*.log
  • gzip adsl.2024.oct.tar

With, of course, suitable replacements for the month, year and the type of the log file.