Created
September 8, 2019 13:58
-
-
Save stucka/f144b1a38833ad6edc9415fdbcf85e9d to your computer and use it in GitHub Desktop.
Compile Apache access logs from archives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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