Compress and remove old jetty logs

We are seeing disk space filling up regularly on ask.openstack.org and
mostly it comes from Jetty logs.  Right now, nobody really seems to
know how to turn these logs down or redirect them to something smarter
than can compress and rotate (that actually appears to be harder than
it sounds, and involves importing log4j stuff into the classpath,
etc).

In the mean time, compress the previous days jobs in a cron job.
Since we're also renaming the files, jetty's very simple rotate won't
remove the old ones, so add another job to keep just a weeks worth.

Change-Id: Ib78039f0b6764408ba5ce5111d92560f1b8ef6f6
This commit is contained in:
Ian Wienand 2016-12-05 13:21:57 +11:00
parent 8f84e57f53
commit b458291e8e
1 changed files with 23 additions and 0 deletions

View File

@ -51,4 +51,27 @@ class askbot::site::cron (
File["${site_root}/cron/clean_session.sh"],
]
}
# gzip old jetty logs
cron { 'jetty-log-gzip':
user => 'root',
hour => '1',
minute => '0',
# Jetty just outputs to a log file YYYY_mm_dd.log, thus
# we do not want to touch the current days log as that is active
command => "find /var/log/jetty \\( ! -daystart -mtime 0 \\) -a -name '*.log' -execdir gzip {} \\;",
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin'
}
# remove old jetty logs
cron { 'jetty-log-cleanup':
user => 'root',
hour => '1',
minute => '30',
# because we're gzipping logs behind jetty's back, remove the old
# logs after a period.
command => "find /var/log/jetty -name '*.log.gz' -mtime +7 -execdir rm {} \\;",
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin'
}
}