Skip to content

Instantly share code, notes, and snippets.

@stucka
Created September 8, 2019 13:58
Show Gist options
  • Save stucka/f144b1a38833ad6edc9415fdbcf85e9d to your computer and use it in GitHub Desktop.
Save stucka/f144b1a38833ad6edc9415fdbcf85e9d to your computer and use it in GitHub Desktop.
Compile Apache access logs from archives
#!/bin/python3
import gzip
import glob
gzippedfiles = list(glob.glob("access.log*.gz"))
with open("accesscompiled.log", "wb") as outfile:
with open("access.log", "rb") as infile:
outfile.write(infile.read())
with open("access.log.1", "rb") as infile:
outfile.write(infile.read())
for gzippedfile in gzippedfiles:
with gzip.open(gzippedfile, "rb") as infile:
outfile.write(infile.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment